module Modifiers::Querying

Public Instance Methods

duplicate_ivars!() click to toggle source
# 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() click to toggle source
# 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
reset_ivars(hash) click to toggle source
# File lib/modifiers/query.rb, line 15
def reset_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