module Gorillib::Hashlike::Serialization

Public Instance Methods

to_wire(options={}) click to toggle source

Returns a hash with each key set to its associated value

@example

my_hshlike = MyHashlike.new
my_hshlike[:a] = 100; my_hshlike[:b] = 200
my_hshlike.to_hash # => { :a => 100, :b => 200 }

@return [Hash] a new Hash instance, with each key set to its associated value.

# File lib/gorillib/serialization/to_wire.rb, line 15
def to_wire(options={})
  {}.tap do |hsh|
    each do |attr,val|
      hsh[attr] =
        case
        when val.respond_to?(:to_wire) then val.to_wire(options)
        when val.respond_to?(:to_hash) then val.to_hash
        else val ; end
    end
  end
end