Fully qualifying calls to ActiveRecord; replacing + char with backticks in comments for better documentation [ci skip]
This commit is contained in:
parent
f76bcc8915
commit
a7e11f6fe9
|
@ -17,7 +17,7 @@ module PaperTrail
|
|||
end
|
||||
|
||||
def self.next_migration_number(dirname)
|
||||
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
||||
::ActiveRecord::Generators::Base.next_migration_number(dirname)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -79,7 +79,7 @@ module PaperTrail
|
|||
end
|
||||
|
||||
def self.active_record_protected_attributes?
|
||||
@active_record_protected_attributes ||= ActiveRecord::VERSION::STRING.to_f < 4.0 || !!defined?(ProtectedAttributes)
|
||||
@active_record_protected_attributes ||= ::ActiveRecord::VERSION::STRING.to_f < 4.0 || !!defined?(ProtectedAttributes)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -13,7 +13,7 @@ module PaperTrail
|
|||
# Options:
|
||||
# :on the events to track (optional; defaults to all of them). Set to an array of
|
||||
# `:create`, `:update`, `:destroy` as desired.
|
||||
# :class_name the name of a custom Version class. This class should inherit from Version.
|
||||
# :class_name the name of a custom Version class. This class should inherit from `PaperTrail::Version`.
|
||||
# :ignore an array of attributes for which a new `Version` will not be created if only they change.
|
||||
# it can also aceept a Hash as an argument where the key is the attribute to ignore (a `String` or `Symbol`),
|
||||
# which will only be ignored if the value is a `Proc` which returns truthily.
|
||||
|
@ -63,7 +63,7 @@ module PaperTrail
|
|||
|
||||
attr_accessor :paper_trail_event
|
||||
|
||||
if ActiveRecord::VERSION::STRING.to_f >= 4.0 # `has_many` syntax for specifying order uses a lambda in Rails 4
|
||||
if ::ActiveRecord::VERSION::STRING.to_f >= 4.0 # `has_many` syntax for specifying order uses a lambda in Rails 4
|
||||
has_many self.versions_association_name,
|
||||
lambda { order("#{PaperTrail.timestamp_field} ASC") },
|
||||
:class_name => self.version_class_name, :as => :item
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module PaperTrail
|
||||
class Version < ActiveRecord::Base
|
||||
class Version < ::ActiveRecord::Base
|
||||
belongs_to :item, :polymorphic => true
|
||||
validates_presence_of :event
|
||||
attr_accessible :item_type, :item_id, :event, :whodunnit, :object, :object_changes if PaperTrail.active_record_protected_attributes?
|
||||
|
@ -49,7 +49,7 @@ module PaperTrail
|
|||
# opt out.
|
||||
#
|
||||
# Options:
|
||||
# +:has_one+ set to `false` to opt out of has_one reification.
|
||||
# :has_one set to `false` to opt out of has_one reification.
|
||||
# set to a float to change the lookback time (check whether your db supports
|
||||
# sub-second datetimes if you want them).
|
||||
def reify(options = {})
|
||||
|
@ -62,16 +62,16 @@ module PaperTrail
|
|||
|
||||
# Normally a polymorphic belongs_to relationship allows us
|
||||
# to get the object we belong to by calling, in this case,
|
||||
# +item+. However this returns nil if +item+ has been
|
||||
# `item`. However this returns nil if `item` has been
|
||||
# destroyed, and we need to be able to retrieve destroyed
|
||||
# objects.
|
||||
#
|
||||
# In this situation we constantize the +item_type+ to get hold of
|
||||
# In this situation we constantize the `item_type` to get hold of
|
||||
# the class...except when the stored object's attributes
|
||||
# include a +type+ key. If this is the case, the object
|
||||
# include a `type` key. If this is the case, the object
|
||||
# we belong to is using single table inheritance and the
|
||||
# +item_type+ will be the base class, not the actual subclass.
|
||||
# If +type+ is present but empty, the class is the base class.
|
||||
# `item_type` will be the base class, not the actual subclass.
|
||||
# If `type` is present but empty, the class is the base class.
|
||||
|
||||
if item
|
||||
model = item
|
||||
|
@ -151,8 +151,8 @@ module PaperTrail
|
|||
# In Rails 3.1+, calling reify on a previous version confuses the
|
||||
# IdentityMap, if enabled. This prevents insertion into the map.
|
||||
def without_identity_map(&block)
|
||||
if defined?(ActiveRecord::IdentityMap) && ActiveRecord::IdentityMap.respond_to?(:without)
|
||||
ActiveRecord::IdentityMap.without(&block)
|
||||
if defined?(::ActiveRecord::IdentityMap) && ::ActiveRecord::IdentityMap.respond_to?(:without)
|
||||
::ActiveRecord::IdentityMap.without(&block)
|
||||
else
|
||||
block.call
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue