Class: Struct

Inherits:
Object show all
Defined in:
lib/core/facets/struct/replace.rb,
lib/core/facets/struct/attributes.rb,
lib/core/facets/object/object_state.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject

Returns a hash containing the names and values for all instance settings in the Struct.

This will eventually be deprecated in favor of #to_h.



8
9
10
11
12
# File 'lib/core/facets/struct/attributes.rb', line 8

def attributes
  h = {}
  each_pair { |k,v| h[k] = v }
  h
end

#object_state(data = nil) ⇒ Object



68
69
70
71
72
73
74
75
76
# File 'lib/core/facets/object/object_state.rb', line 68

def object_state(data=nil)
  if data
    data.each_pair {|k,v| send(k.to_s + "=", v)}
  else
    data = {}
    each_pair{|k,v| data[k] = v}
    data
  end
end

#replace(source) ⇒ Object

Struct#replace can take any source that responds to #each_pair.



4
5
6
# File 'lib/core/facets/struct/replace.rb', line 4

def replace(source)
  source.each_pair{ |k,v| send(k.to_s + "=", v) }
end