Method: Mongoid::Touchable#define_touchable!
- Defined in:
- lib/mongoid/touchable.rb
#define_touchable!(association) ⇒ Class
Add the association to the touchable associations if the touch option was provided.
153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/mongoid/touchable.rb', line 153 def define_touchable!(association) name = association.name method_name = define_relation_touch_method(name, association) association.inverse_class.tap do |klass| klass.after_save method_name klass.after_destroy method_name # Embedded docs handle touch updates recursively within # the #touch method itself klass.after_touch method_name unless association. end end |