Module: RubyVolt::DataType::Extensions::CodeValuesHash

Included in:
AppDataType, SerializableException
Defined in:
lib/ruby_volt/data_type/extensions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#code_valuesObject (readonly)

Returns the value of attribute code_values.



6
7
8
# File 'lib/ruby_volt/data_type/extensions.rb', line 6

def code_values
  @code_values
end

#codesObject (readonly)

Returns the value of attribute codes.



6
7
8
# File 'lib/ruby_volt/data_type/extensions.rb', line 6

def codes
  @codes
end

Instance Method Details

#hash_codes(*arrays) ⇒ Object



12
13
14
15
# File 'lib/ruby_volt/data_type/extensions.rb', line 12

def hash_codes(*arrays)
  @codes ||= Hash[arrays]
  @code_values ||= Hash[arrays.map(&:reverse)]
end

#inherited(child) ⇒ Object



8
9
10
# File 'lib/ruby_volt/data_type/extensions.rb', line 8

def inherited(child)
  child.instance_variable_set(:@codes, Hash[@codes.map {|a| [a[0], a[1].dup]}]) if instance_variable_defined?("@codes")
end