Module: Etapper::Hashable

Included in:
DefinedValue, Phone
Defined in:
lib/etapper/classes/hashable.rb

Overview

Abstract utility methods for maintaining useful hashes from collections of complex types

Instance Method Summary collapse

Instance Method Details

#append_to_hash(hash) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/etapper/classes/hashable.rb', line 9

def append_to_hash(hash)
  hash ||= Hash.new
  if hash.has_key?(key)
    arr = Array(hash[key])
    hash[key] = arr.push(value)
    hash
  else
    hash.merge(self.to_hash)
  end
end

#to_hashObject



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

def to_hash
  {key => value}
end