Sha256: a6864bbd2c8c5e6dba7cf0031c0e331a7f91c89cd54c39e1d32bc0d32a95e973

Contents?: true

Size: 670 Bytes

Versions: 1

Compression:

Stored size: 670 Bytes

Contents

module Mongoid
  module History
    GLOBAL_TRACK_HISTORY_FLAG = "mongoid_history_trackable_enabled"

    mattr_accessor :tracker_class_name
    mattr_accessor :trackable_class_options
    mattr_accessor :modifier_class_name
    mattr_accessor :current_user_method

    def self.tracker_class
      @tracker_class ||= tracker_class_name.to_s.classify.constantize
    end

    def self.disable(&block)
      begin
        Thread.current[GLOBAL_TRACK_HISTORY_FLAG] = false
        yield
      ensure
        Thread.current[GLOBAL_TRACK_HISTORY_FLAG] = true
      end
    end

    def self.enabled?
      Thread.current[GLOBAL_TRACK_HISTORY_FLAG] != false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-history-0.4.0 lib/mongoid/history.rb