Revision support for Og-managed classes.

class Article

  is Revisable
  attr_accessor :body, String, :revisable => true
  attr_accessor :title, String

end

Generates the Revision class:

class Article::Revision

article.revisions

article.revise do |a|

  a.title = 'hello'
  a.body = 'world'

end

article.rollback(4)

Methods
Classes and Modules
Module Og::Mixin::Revisable::Mixin
Attributes
[RW] revision The revision of the revisable object.
Public Class methods
included(base)
    # File lib/og/model/revisable.rb, line 63
63:   def self.included base
64:     super
65:     
66:     base.module_eval %{
67:       class Revision < #{base}
68:         include Revisable::Mixin
69:         refers_to #{base}
70:       end
71:     }
72:     
73:     base.has_many :revisions, base::Revision
74:   end
Public Instance methods
get_revision(rev)

Return a revision.

     # File lib/og/model/revisable.rb, line 99
 99:   def get_revision rev
100:     return self if rev.to_i == self.revision
101:     self.revisions.find_one(:condition => "revision=#{rev}")
102:   end
last_revision()

Return the last revision.

     # File lib/og/model/revisable.rb, line 106
106:   def last_revision
107:     self.revisions(:order => 'revision DESC', :limit => 1).first
108:   end
revise(options = {}) {|self| ...}

Can accept options like owner or a comment. You can specialize this in your app.

This method is also aliased as revise!
    # File lib/og/model/revisable.rb, line 79
79:   def revise options = {}
80:     if self.revision.nil? 
81:       self.revision = 1 
82:     else
83:       self.revision += 1
84:     end
85:     self.revisions << self.class::Revision.new(self, options)
86:     yield(self) if block_given?
87:     self.save
88:   end
revise!(options = {})

Alias for #revise

revision_count()

The number of revisions.

This method is also aliased as revisions_count
     # File lib/og/model/revisable.rb, line 112
112:   def revision_count
113:     self.revisions.count
114:   end
revisions_count()

Alias for #revision_count

rollback(rev, options = {})

Rollback to an older revision.

    # File lib/og/model/revisable.rb, line 93
93:   def rollback rev, options = {}
94:     self.revise(options) { |obj| get_revision(rev).apply_to(obj) }
95:   end