Sha256: d322b4c7f8194ed6a033b0a851c7acfa0ad43f2ed83ec662a3f1c073d0fbe754

Contents?: true

Size: 641 Bytes

Versions: 3

Compression:

Stored size: 641 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)
      Thread.current[GLOBAL_TRACK_HISTORY_FLAG] = false
      yield
    ensure
      Thread.current[GLOBAL_TRACK_HISTORY_FLAG] = true
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid-history-0.4.4 lib/mongoid/history.rb
mongoid-history-0.4.3 lib/mongoid/history.rb
mongoid-history-0.4.2 lib/mongoid/history.rb