Module: MmUsesNoId
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mm_uses_no_id.rb,
lib/mm_uses_no_id/version.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
"0.0.5"
Instance Method Summary collapse
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
16 17 18 |
# File 'lib/mm_uses_no_id.rb', line 16 def eql?(other) other.is_a?(self.class) && other.attributes == attributes end |
#initialize_copy(other) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# 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 |