Class: Struct

Inherits:
Object show all
Defined in:
lib/roebe/core/struct.rb

Overview

#

Struct modifications can be stored here.

#

Direct Known Subclasses

FormTable::Contact

Instance Method Summary collapse

Instance Method Details

#to_hashObject

#

to_hash

Usage example:

Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", ["123 Maple", "Anytown NC"], 12345)
joe.to_hash # => {"name"=>"Joe Smith", "zip"=>12345, "address"=>["123 Maple", "Anytown NC"]}
#


16
17
18
19
20
# File 'lib/roebe/core/struct.rb', line 16

def to_hash
  members.zip(values).inject({ }) {|hash, (key, value)|
    hash.merge(key => value)
  }
end