Module: HasModerated::Associations::HasOne::AssociationPatches
- Defined in:
- lib/has_moderated/associations/has_one.rb
Instance Method Summary collapse
Instance Method Details
#replace_with_moderation(record, save = true) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/has_moderated/associations/has_one.rb', line 5 def replace_with_moderation(record, save = true) # TODO: code duplication if owner.new_record? || owner.moderation_disabled replace_without_moderation record else if record.blank? # use dummy value so it's not nil owner.delete_associations_moderated(self.reflection.name => [1]) else owner.add_associations_moderated(self.reflection.name => [record]) end record end end |