Class: Musterb::ObjectExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/musterb/object_extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, parent) ⇒ ObjectExtractor

Returns a new instance of ObjectExtractor.



4
5
6
7
# File 'lib/musterb/object_extractor.rb', line 4

def initialize(value, parent)
  @value = value
  @parent = parent
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



2
3
4
# File 'lib/musterb/object_extractor.rb', line 2

def parent
  @parent
end

#valueObject (readonly)

Returns the value of attribute value.



2
3
4
# File 'lib/musterb/object_extractor.rb', line 2

def value
  @value
end

Instance Method Details

#[](symbol) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/musterb/object_extractor.rb', line 9

def [](symbol)    
  if @value.respond_to? symbol
    @value.send(symbol)
  else
    @parent[symbol]
  end
end