Module: MmDirtier::OneEmbeddedProxyListener

Includes:
Observables::Base
Defined in:
lib/mm_dirtier/one_embedded_proxy_listener.rb

Instance Method Summary collapse

Instance Method Details

#cloneObject



26
27
28
# File 'lib/mm_dirtier/one_embedded_proxy_listener.rb', line 26

def clone
  target
end

#duplicable?Boolean

This is a dirty hack. duplicable? has to return true, or the ActiveModel::Dirty will store the proxy in its change set, and then when you check for changes it will always reflect the latest value of its target, which isn’t what is desired. However, duplicating an embedded document gives it a new object ID, which ruins the identity of the child and isn’t what we want either. Thus this nasty, nasty business. There must be a better way, but at the moment it escapes me.

Returns:

  • (Boolean)


22
23
24
# File 'lib/mm_dirtier/one_embedded_proxy_listener.rb', line 22

def duplicable?
  true
end

#replace(val) ⇒ Object



5
6
7
# File 'lib/mm_dirtier/one_embedded_proxy_listener.rb', line 5

def replace(val)
  changing(:modifier) {super}
end