Module: Mongoid::Relations::Touchable::ClassMethods

Defined in:
lib/mongoid/relations/touchable.rb

Instance Method Summary collapse

Instance Method Details

#touchable(metadata) ⇒ Class

Add the metadata to the touchable relations if the touch option was provided.

Examples:

Add the touchable.

Model.touchable(meta)

Parameters:

  • metadata (Metadata)

    The relation metadata.

Returns:

  • (Class)

    The model class.

Since:

  • 3.0.0


53
54
55
56
57
58
59
60
61
62
# File 'lib/mongoid/relations/touchable.rb', line 53

def touchable()
  if .touchable?
    name = .name
    method_name = define_relation_touch_method(name)
    after_save method_name
    after_destroy method_name
    after_touch method_name
  end
  self
end