Class: Musterb::InstanceVariableExtractor
- Inherits:
-
Object
- Object
- Musterb::InstanceVariableExtractor
- Defined in:
- lib/musterb/instance_variable_extractor.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #[](symbol) ⇒ Object
-
#initialize(value, parent) ⇒ InstanceVariableExtractor
constructor
A new instance of InstanceVariableExtractor.
Constructor Details
#initialize(value, parent) ⇒ InstanceVariableExtractor
Returns a new instance of InstanceVariableExtractor.
4 5 6 7 |
# File 'lib/musterb/instance_variable_extractor.rb', line 4 def initialize(value, parent) @value = value @parent = parent end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
2 3 4 |
# File 'lib/musterb/instance_variable_extractor.rb', line 2 def parent @parent end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
2 3 4 |
# File 'lib/musterb/instance_variable_extractor.rb', line 2 def value @value end |
Instance Method Details
#[](symbol) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/musterb/instance_variable_extractor.rb', line 9 def [](symbol) if value.instance_variable_defined?("@#{symbol}") value.instance_variable_get("@#{symbol}") else @parent[symbol] end end |