Sha256: 85152dac51cf59e57825723833781c8f817101b99205b8a76696839f22c818e4

Contents?: true

Size: 411 Bytes

Versions: 6

Compression:

Stored size: 411 Bytes

Contents

module Etapper
  
  # Abstract utility methods for maintaining useful hashes from collections of complex types
  module Hashable
    def to_hash
      {key => value}
    end
    
    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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
etapper-0.0.5 lib/etapper/classes/hashable.rb
etapper-0.0.4 lib/etapper/classes/hashable.rb
etapper-0.0.3 lib/etapper/classes/hashable.rb
etapper-0.0.2 lib/etapper/classes/hashable.rb
etapper-0.0.1 lib/etapper/classes/hashable.rb
etapper-0.0.0 lib/etapper/classes/hashable.rb