Module: Modifiers::Querying
- Defined in:
- lib/modifiers/query.rb
Instance Method Summary collapse
Instance Method Details
#duplicate_ivars! ⇒ Object
11 12 13 |
# File 'lib/modifiers/query.rb', line 11 def duplicate_ivars! ivars_hash.each { |k,v| instance_variable_set(k, Marshal.load(Marshal.dump(v))) } end |
#ivars_hash ⇒ Object
5 6 7 8 9 |
# File 'lib/modifiers/query.rb', line 5 def ivars_hash instance_variables.each_with_object({}) do |ivar, hash| hash[ivar] = instance_variable_get(ivar) end end |
#set_ivars(hash) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/modifiers/query.rb', line 15 def set_ivars(hash) hash.each { |k, v| instance_variable_set(k, v) } in_state_but_not_hash = instance_variables.select { |i| hash[i].nil? } in_state_but_not_hash.each { |i| remove_instance_variable(i) } end |