module Mongoid::Relations::Touchable::ClassMethods

Public Instance Methods

touchable(metadata) click to toggle source

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

@example Add the touchable.

Model.touchable(meta)

@param [ Metadata ] metadata The relation metadata.

@return [ Class ] The model class.

@since 3.0.0

# File lib/mongoid/relations/touchable.rb, line 19
def touchable(metadata)
  if metadata.touchable?
    name = metadata.name
    method_name = define_relation_touch_method(name)
    after_create method_name
    after_destroy method_name
    after_touch method_name
  end
  self
end