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

Defined in:
build/mongoid-6.4/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
63
# File 'build/mongoid-6.4/lib/mongoid/relations/touchable.rb', line 53

def touchable()
  if .touchable?
    name = .name
    field = [:touch].is_a?(Symbol) ? [:touch] : nil
    method_name = define_relation_touch_method(name, field)
    after_save method_name
    after_destroy method_name
    after_touch method_name
  end
  self
end