module MmUsesNoId

Constants

VERSION

Public Instance Methods

==(other)
Alias for: eql?
eql?(other) click to toggle source
# File lib/mm_uses_no_id.rb, line 16
def eql?(other)
  other.is_a?(self.class) && other.attributes == attributes
end
Also aliased as: ==
initialize_copy(other) click to toggle source
# File lib/mm_uses_no_id.rb, line 21
def initialize_copy(other)
  @_new       = true
  @_destroyed = false
  
  begin
    remove_instance_variable(:@_id)
    remove_instance_variable(:@_id_before_type_cast)
  rescue
  end

  associations.each do |name, association|
    instance_variable_set(association.ivar, nil)
  end
  self.attributes = other.attributes.clone.except(:_id).inject({}) do |hash, entry|
    key, value = entry
    hash[key] = value.duplicable? ? value.clone : value
    hash
  end
end