Class: BitmaskAttribute::ValueProxy

Inherits:
Array show all
Defined in:
lib/bitmask_attribute/value_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(record, attribute, &extension) ⇒ ValueProxy

Returns a new instance of ValueProxy.



5
6
7
8
9
10
11
# File 'lib/bitmask_attribute/value_proxy.rb', line 5

def initialize(record, attribute, &extension)
  @record = record
  @attribute = attribute
  find_mapping
  instance_eval(&extension) if extension
  super(extract_values)
end

Instance Method Details

#to_iObject



27
28
29
# File 'lib/bitmask_attribute/value_proxy.rb', line 27

def to_i
  inject(0) { |memo, value| memo | @mapping[value] }
end