lib/volt/models/url.rb
# Loop through the old params, and overwrite any existing values,
# and delete the values that don't exist in the new params.  Also
# remove any assigned to the new params (query_hash)
Loop through the old params, and overwrite any existing values,
and delete the values that don't exist in the new params.  Also
remove any assigned to the new params (query_hash)
Loop through the old params and overwrite any existing values and delete the values that don ' t exist in the new params . Also remove any assigned to the new params ( query_hash )
def assign_from_old(params, new_params)
      queued_deletes = []
      params.cur.attributes.each_pair do |name,old_val|
        new_val = new_params ? new_params[name] : nil
        if !new_val
          queued_deletes << name
        elsif new_val.is_a?(Hash)
          assign_from_old(old_val, new_val)
        else
          if old_val != new_val
            params.send(:"#{name}=", new_val)
          end
          new_params.delete(name)
        end
      end
      queued_deletes.each {|name| params.delete(name) }
    end
def assign_from_old ( params , new_params ) queued_deletes = [ ] params . cur . attributes . each_pair do | name , old_val | new_val = new_params ? new_params [ name ] : nil if ! new_val queued_deletes << name elsif new_val . is_a? ( Hash ) assign_from_old ( old_val , new_val ) else if old_val != new_val params . send ( :" #{ name } = " , new_val ) end new_params . delete ( name ) end end queued_deletes . each { | name | params . delete ( name ) } end
Loop through the old params, and overwrite any existing values,
and delete the values that don't exist in the new params.
Loop through the old params and overwrite any existing values and delete the values that don ' t exist in the new params .
# If there is a new value, see if it has [name] # Queues the delete until after we finish the each_pair loop # assign value
params
new_params