module UpDupable
From gist.github.com/eliav-lavi/1b739bc57719bd9755f2dee3f5a02cef#file-up_dupable-rb by Eliav Lavi (github.com/eliav-lavi)
Public Instance Methods
dup_and_update(**args)
click to toggle source
# File lib/universities/up_dupable.rb, line 6 def dup_and_update(**args) self.class.new(clean_ivars.merge(args)) end
Private Instance Methods
clean_ivars()
click to toggle source
# File lib/universities/up_dupable.rb, line 12 def clean_ivars instance_variables_get.each_with_object({}) { |(k, v), hash| hash[k.to_s.delete('@').to_sym] = v } end
instance_variables_get()
click to toggle source
# File lib/universities/up_dupable.rb, line 16 def instance_variables_get instance_variables.each_with_object({}) { |ivar, hash| hash[ivar] = instance_variable_get(ivar) } end