Module: Sequel::Plugins::Touch::InstanceMethods
- Defined in:
- lib/sequel/plugins/touch.rb
Instance Method Summary collapse
-
#after_create ⇒ Object
Touch all of the model’s touched_associations when creating the object.
-
#after_destroy ⇒ Object
Touch all of the model’s touched_associations when destroying the object.
-
#after_update ⇒ Object
Touch all of the model’s touched_associations when updating the object.
-
#touch(column = nil) ⇒ Object
Touch the model object.
Instance Method Details
#after_create ⇒ Object
Touch all of the model’s touched_associations when creating the object.
89 90 91 92 |
# File 'lib/sequel/plugins/touch.rb', line 89 def after_create super touch_associations end |
#after_destroy ⇒ Object
Touch all of the model’s touched_associations when destroying the object.
95 96 97 98 |
# File 'lib/sequel/plugins/touch.rb', line 95 def after_destroy super touch_associations end |
#after_update ⇒ Object
Touch all of the model’s touched_associations when updating the object.
101 102 103 104 |
# File 'lib/sequel/plugins/touch.rb', line 101 def after_update super touch_associations end |
#touch(column = nil) ⇒ Object
Touch the model object. If a column is not given, use the model’s touch_column as the column. If the column to use is not one of the model’s columns, just save the changes to the object instead of attempting to a value that doesn’t exist.
110 111 112 113 114 115 116 117 118 |
# File 'lib/sequel/plugins/touch.rb', line 110 def touch(column=nil) if column set(column=>touch_instance_value) else column = model.touch_column set(column=>touch_instance_value) if columns.include?(column) end save_changes end |