Module: Mongoid::Touchable
Defined Under Namespace
Modules: InstanceMethods
Instance Method Summary collapse
-
#define_touchable!(association) ⇒ Class
Add the association to the touchable associations if the touch option was provided.
-
#suppress_touch_callbacks(name) ⇒ Object
private
Suppresses touch callbacks for the named class, for the duration of the associated block.
-
#touch_callbacks_suppressed?(name) ⇒ true | false
private
Queries whether touch callbacks are being suppressed for the named class.
Instance Method Details
#define_touchable!(association) ⇒ Class
Add the association to the touchable associations if the touch option was provided.
145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/mongoid/touchable.rb', line 145 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 |
#suppress_touch_callbacks(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Suppresses touch callbacks for the named class, for the duration of the associated block.
162 163 164 165 166 167 |
# File 'lib/mongoid/touchable.rb', line 162 def suppress_touch_callbacks(name) save, touch_callback_statuses[name] = touch_callback_statuses[name], true yield ensure touch_callback_statuses[name] = save end |
#touch_callbacks_suppressed?(name) ⇒ true | false
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Queries whether touch callbacks are being suppressed for the named class.
175 176 177 |
# File 'lib/mongoid/touchable.rb', line 175 def touch_callbacks_suppressed?(name) touch_callback_statuses[name] end |