Module: CustomFields::Types::Default::Field
- Defined in:
- lib/custom_fields/types/default.rb
Instance Method Summary collapse
-
#collect_default_diff(memo) ⇒ Hash
Build the mongodb updates based on the new state of the field.
Instance Method Details
#collect_default_diff(memo) ⇒ Hash
Build the mongodb updates based on the new state of the field
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/custom_fields/types/default.rb', line 16 def collect_default_diff(memo) # puts "collect_default_diff #{self.name}: #{self.persisted?} / #{self.destroyed?}" # DEBUG if self.persisted? if self.destroyed? memo['$unset'][self.name] = 1 elsif self.changed? if self.changes.key?('name') old_name, new_name = self.changes['name'] memo['$rename'][old_name] = new_name end end end (memo['$set']['custom_fields_recipe.rules'] ||= []) << self.to_recipe memo end |