lib/garcon/core_ext/struct.rb
# Get a hash with names and values of all instance variables.
#
# @example
#   class Foo < Struct.new(:name, :age, :gender); end
#   f = Foo.new("Jill", 50, :female)
#   f.attributes   # => {:name => "Jill", :age => 50, :gender => :female}
#
# @return [Hash]
#   Hash of instance variables in receiver, keyed by ivar name
Get a hash with names and values of all instance variables.
Get a hash with names and values of all instance variables .
def attributes
    h = {}
    each_pair { |key, value| h[key] = value }
    h
  end
def attributes h = { } each_pair { | key , value | h [ key ] = value } h end
Get a hash with names and values of all instance variables.
Get a hash with names and values of all instance variables .
Hash of instance variables in receiver, keyed by ivar name
Hash of instance variables in receiver keyed by ivar name
Hash
example
class Foo < Struct.new(:name, :age, :gender); end f = Foo.new("Jill", 50, :female) f.attributes # => {:name => "Jill", :age => 50, :gender => :female}
class Foo < Struct . new ( : name : age : gender ) ; end f = Foo . new ( " Jill " 50 : female ) f . attributes # = > { : name = > " Jill " : age = > 50 : gender = > : female }