Skip to content

Commit

Permalink
fix: add extractor back for capability
Browse files Browse the repository at this point in the history
  • Loading branch information
artofhuman committed Apr 19, 2017
1 parent 570ec1d commit 91f8ef7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/treasury/fields/extractor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Treasury
module Fields
# Public: Модуль добавляет классу метод extract_object, подходит для источников и полей денормализации.
#
# Deprecated: For extract object use Apress::Sources::ExtractObject module
#
# Example:
#
# class Field
# extend ::Treasury::Fields::Extractor
# extract_attribute_name :user
# end
#
# Field.extract_object(object: {user_id: 1})
# => 1
module Extractor
def self.extended(base)
warn "[DEPRECATION] Please use `extend Apress::Sources::ExtractObject` instead Treasury::Fields::Extractor"
base.extend(Apress::Sources::ExtractObject)
end
end
end
end
13 changes: 13 additions & 0 deletions spec/lib/treasury/fields/extractor_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
RSpec.describe Treasury::Fields::Extractor do
let(:class_with_extractor) do
Class.new do
extend Treasury::Fields::Extractor

extract_attribute_name :user
end
end

describe '.extract_object' do
it { expect(class_with_extractor.extract_user(object: {user_id: 1})).to eq 1 }
end
end

0 comments on commit 91f8ef7

Please sign in to comment.