Module: Revisions::ClassMethods

Defined in:
lib/revisions.rb

Constant Summary collapse

STATUSES =
['draft', 'published', 'revision']

Instance Method Summary collapse

Instance Method Details

#has_revisions(opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/revisions.rb', line 6

def has_revisions opts={}
  class_attribute :unrevised_attributes
  
  has_many :revisions,  
    :class_name => self.name, 
    :conditions => "status='revision'",
    :foreign_key => 'revision_of'
  
  include InstanceMethods
  
  self.unrevised_attributes = opts[:ignore] || []
  self.unrevised_attributes.concat ['revision_of', 'status', 'created_at', 'updated_at', 'id']
end