Class: AdvAccessor::BaseReaders

Inherits:
Object
  • Object
show all
Includes:
FromHash
Defined in:
lib/adv_accessor/mapping.rb

Direct Known Subclasses

Mappings, Readers

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#baseObject

Returns the value of attribute base.



23
24
25
# File 'lib/adv_accessor/mapping.rb', line 23

def base
  @base
end

Instance Method Details

#<<(x) ⇒ Object



25
26
27
# File 'lib/adv_accessor/mapping.rb', line 25

def <<(x)
  self.list << x
end

#get(ops) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/adv_accessor/mapping.rb', line 28

def get(ops)
  ops[:val] ||= base.value
  list.each do |m|
    if m.match?(ops)
      os = OpenStruct.new(:value => ops[:val], :raw_value => base.raw_value)
      return m.block[os]
    end
  end
  raise "cant convert #{ops.inspect}"
end