Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: 4762bfd316
...
compare: 9dbe45bb71
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 24 additions and 22 deletions.
  1. +24 −22 lib/acts_as_versioned.rb
View
46 lib/acts_as_versioned.rb
@@ -1,36 +1,38 @@
+require 'active_support/concern' unless defined?(ActiveSupport)
+
module MongoMapper
module Acts
module Versioned
- VERSION = '0.0.11'
- CALLBACKS = [:save_version, :save_version?, :clear_old_versions]
+ extend ActiveSupport::Concern
- def self.configure(model)
- model.class_eval do
- cattr_accessor :versioned_class_name, :non_versioned_keys, :max_version_limit
+ VERSION = '0.0.12'
+ CALLBACKS = [:save_version, :clear_old_versions]
- self.versioned_class_name = :Version
- self.max_version_limit = 0
- self.non_versioned_keys = %w(
- _id _type created_at updated_at creator_id updater_id version
- )
+ included do
+ cattr_accessor :versioned_class_name, :non_versioned_keys, :max_version_limit
- const_set(versioned_class_name, Class.new).class_eval do
- include MongoMapper::EmbeddedDocument
+ self.versioned_class_name = :Version
+ self.max_version_limit = 0
+ self.non_versioned_keys = %w(
+ _id _type created_at updated_at creator_id updater_id version
+ )
- key :version, Integer
- key :modified, Hash
- end
+ const_set(versioned_class_name, Class.new).class_eval do
+ include MongoMapper::EmbeddedDocument
- many :versions, :class => "#{self}::#{versioned_class_name}".constantize do
- def [](version)
- detect { |doc| doc.version.to_s == version.to_s }
- end
+ key :version, Integer
+ key :modified, Hash
+ end
+
+ many :versions, :class => "#{self}::#{versioned_class_name}".constantize do
+ def [](version)
+ detect { |doc| doc.version.to_s == version.to_s }
end
end
- model.key :version, Integer
- model.before_save :save_version
- model.before_save :clear_old_versions
+ key :version, Integer
+ before_save :save_version
+ before_save :clear_old_versions
end
module InstanceMethods

No commit comments for this range

Something went wrong with that request. Please try again.