Class/Module Index [+]

Quicksearch

Sequel::Plugins::Touch::ClassMethods

Attributes

touch_column[RW]

The column to modify when touching a model instance, as a symbol. Also used as the default column when touching associations, if the associations don't specify a column.

touched_associations[R]

A hash specifying the associations to touch when instances are updated or destroyed. Keys are association name symbols and values are column name symbols.

Public Instance Methods

inherited(subclass) click to toggle source

Set the touch_column for the subclass to be the same as the current class. Also, create a copy of the touched_associations in the subclass.

# File lib/sequel/plugins/touch.rb, line 61
def inherited(subclass)
  super
  subclass.touch_column = touch_column
  subclass.instance_variable_set(:@touched_associations, touched_associations.dup)
end
touch_associations(*associations) click to toggle source

Add additional associations to be touched. See the :association option of the Sequel::Plugin::Touch.configure method for the format of the associations arguments.

# File lib/sequel/plugins/touch.rb, line 70
def touch_associations(*associations)
  associations.flatten.each do |a|
    a = {a=>touch_column} if a.is_a?(Symbol)
    a.each do |k,v|
      raise(Error, "invalid association: #{k}") unless association_reflection(k)
      touched_associations[k] = v
    end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.