Class: Fabrique::BeanPropertyReference
- Inherits:
-
Object
- Object
- Fabrique::BeanPropertyReference
- Defined in:
- lib/fabrique/bean_property_reference.rb
Instance Attribute Summary collapse
-
#bean ⇒ Object
readonly
Returns the value of attribute bean.
Instance Method Summary collapse
-
#initialize(bean_property) ⇒ BeanPropertyReference
constructor
A new instance of BeanPropertyReference.
- #resolve(bean) ⇒ Object
Constructor Details
#initialize(bean_property) ⇒ BeanPropertyReference
Returns a new instance of BeanPropertyReference.
6 7 8 9 10 11 |
# File 'lib/fabrique/bean_property_reference.rb', line 6 def initialize(bean_property) chain = bean_property.split('.') @bean = chain.first @property_chain = chain.drop(1) @property = @property_chain.join('.') end |
Instance Attribute Details
#bean ⇒ Object (readonly)
Returns the value of attribute bean.
4 5 6 |
# File 'lib/fabrique/bean_property_reference.rb', line 4 def bean @bean end |
Instance Method Details
#resolve(bean) ⇒ Object
13 14 15 |
# File 'lib/fabrique/bean_property_reference.rb', line 13 def resolve(bean) @property_chain.inject(bean) { |acc, property| acc.send(property) } end |