Class: Trader::RawResource
- Inherits:
-
Object
- Object
- Trader::RawResource
- Defined in:
- lib/trade-o-matic/adapters/base/raw_resource.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(_raw) ⇒ RawResource
constructor
A new instance of RawResource.
Constructor Details
#initialize(_raw) ⇒ RawResource
Returns a new instance of RawResource.
25 26 27 |
# File 'lib/trade-o-matic/adapters/base/raw_resource.rb', line 25 def initialize(_raw) @raw = _raw end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
23 24 25 |
# File 'lib/trade-o-matic/adapters/base/raw_resource.rb', line 23 def raw @raw end |
Class Method Details
.attr_mapped(_attr, _path = nil, &_block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/trade-o-matic/adapters/base/raw_resource.rb', line 11 def self.attr_mapped(_attr, _path=nil, &_block) define_method(_attr) do if _block _block.call(raw) elsif _path raw[_path] else raw[_attr.to_s] end end end |
.enforce_attr(*_attrs) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/trade-o-matic/adapters/base/raw_resource.rb', line 3 def self.enforce_attr(*_attrs) _attrs.each do |att| define_method(att) do raise NotImplementedError, "#{att} was not implemented by backend" end end end |