Class: Praxis::Mapper::ForwardingStruct
- Inherits:
-
Object
- Object
- Praxis::Mapper::ForwardingStruct
- Extended by:
- Forwardable
- Defined in:
- lib/praxis/mapper/resource.rb
Overview
Simple Object that will respond to a set of methods, by simply delegating to the target (will also delegate _resource)
Instance Attribute Summary collapse
-
#target ⇒ Object
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(target) ⇒ ForwardingStruct
constructor
A new instance of ForwardingStruct.
Constructor Details
#initialize(target) ⇒ ForwardingStruct
Returns a new instance of ForwardingStruct.
31 32 33 |
# File 'lib/praxis/mapper/resource.rb', line 31 def initialize(target) @target = target end |
Instance Attribute Details
#target ⇒ Object
Returns the value of attribute target.
19 20 21 |
# File 'lib/praxis/mapper/resource.rb', line 19 def target @target end |
Class Method Details
.for(names) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/praxis/mapper/resource.rb', line 21 def self.for(names) Class.new(self) do def_delegator :@target, :_resource def_delegator :@target, :id, :_pk names.each do |(orig, forwarded)| def_delegator :@target, forwarded, orig end end end |