Class: Etapper::DefinedValueHash

Inherits:
EtapHash
  • Object
show all
Defined in:
lib/etapper/classes/defined_value_hash.rb

Instance Attribute Summary

Attributes inherited from EtapHash

#base, #detailed, #etapper_class

Instance Method Summary collapse

Methods inherited from EtapHash

#hash_assign

Constructor Details

#initialize(array_from_api) ⇒ DefinedValueHash

Returns a new instance of DefinedValueHash.



5
6
7
# File 'lib/etapper/classes/defined_value_hash.rb', line 5

def initialize(array_from_api)
   super(array_from_api, DefinedValue, :fieldName, :value)
end

Instance Method Details

#[]=(key, val) ⇒ Object



9
10
11
12
13
# File 'lib/etapper/classes/defined_value_hash.rb', line 9

def []=(key, val)
  add_or_append(key, val)
  # update_base(key, val)
  # hash_assign(key, val)
end

#add_or_append(key, val) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/etapper/classes/defined_value_hash.rb', line 16

def add_or_append(key, val)
  if self.has_key?(key)
    arr = Array(self[key]) << val
    self.update_base(key, arr)
    self.hash_assign(key, arr)
  else
    self.update_base(key, val)
    self.hash_assign(key, val)
  end
end