Module: Sequel::Plugins::Touch::ClassMethods
- Defined in:
- lib/sequel/plugins/touch.rb
Instance Attribute Summary collapse
- 
  
    
      #touch_column  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    The column to modify when touching a model instance, as a symbol. 
- 
  
    
      #touched_associations  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    A hash specifying the associations to touch when instances are updated or destroyed. 
Instance Method Summary collapse
- 
  
    
      #freeze  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Freeze the touched associations when freezing the model class. 
- 
  
    
      #touch_associations(*associations)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Add additional associations to be touched. 
Instance Attribute Details
#touch_column ⇒ Object
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.
| 54 55 56 | # File 'lib/sequel/plugins/touch.rb', line 54 def touch_column @touch_column end | 
#touched_associations ⇒ Object (readonly)
A hash specifying the associations to touch when instances are updated or destroyed. Keys are association name symbols and values are column name symbols.
| 59 60 61 | # File 'lib/sequel/plugins/touch.rb', line 59 def touched_associations @touched_associations end | 
Instance Method Details
#freeze ⇒ Object
Freeze the touched associations when freezing the model class.
| 64 65 66 67 68 | # File 'lib/sequel/plugins/touch.rb', line 64 def freeze @touched_associations.freeze super end | 
#touch_associations(*associations) ⇒ Object
Add additional associations to be touched. See the :association option of the Sequel::Plugin::Touch.configure method for the format of the associations arguments.
| 73 74 75 76 77 78 79 80 81 | # File 'lib/sequel/plugins/touch.rb', line 73 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 |