-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add extractor back for capability
- Loading branch information
1 parent
570ec1d
commit 91f8ef7
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |