Class: Fabrique::BeanPropertyReference

Inherits:
Object
  • Object
show all
Defined in:
lib/fabrique/bean_property_reference.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#beanObject (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