Module: Mongoid::History

Defined in:
lib/mongoid/history.rb,
lib/mongoid/history/options.rb,
lib/mongoid/history/tracker.rb,
lib/mongoid/history/version.rb,
lib/mongoid/history/trackable.rb,
lib/mongoid/history/attributes/base.rb,
lib/mongoid/history/attributes/create.rb,
lib/mongoid/history/attributes/update.rb,
lib/mongoid/history/attributes/destroy.rb

Defined Under Namespace

Modules: Attributes, Trackable, Tracker Classes: Options

Constant Summary collapse

GLOBAL_TRACK_HISTORY_FLAG =
'mongoid_history_trackable_enabled'
VERSION =
'0.6.1'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.current_user_methodObject

Returns the value of attribute current_user_method.



21
22
23
# File 'lib/mongoid/history.rb', line 21

def current_user_method
  @current_user_method
end

.modifier_class_nameObject

Returns the value of attribute modifier_class_name.



20
21
22
# File 'lib/mongoid/history.rb', line 20

def modifier_class_name
  @modifier_class_name
end

.trackable_class_optionsObject

Returns the value of attribute trackable_class_options.



18
19
20
# File 'lib/mongoid/history.rb', line 18

def trackable_class_options
  @trackable_class_options
end

.trackable_settingsObject

Returns the value of attribute trackable_settings.



19
20
21
# File 'lib/mongoid/history.rb', line 19

def trackable_settings
  @trackable_settings
end

.tracker_class_nameObject

Returns the value of attribute tracker_class_name.



17
18
19
# File 'lib/mongoid/history.rb', line 17

def tracker_class_name
  @tracker_class_name
end

Class Method Details

.default_settingsObject



38
39
40
# File 'lib/mongoid/history.rb', line 38

def default_settings
  @default_settings ||= { paranoia_field: 'deleted_at' }
end

.disable(&_block) ⇒ Object



23
24
25
26
27
28
# File 'lib/mongoid/history.rb', line 23

def disable(&_block)
  store[GLOBAL_TRACK_HISTORY_FLAG] = false
  yield
ensure
  store[GLOBAL_TRACK_HISTORY_FLAG] = true
end

.enabled?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/mongoid/history.rb', line 30

def enabled?
  store[GLOBAL_TRACK_HISTORY_FLAG] != false
end

.storeObject



34
35
36
# File 'lib/mongoid/history.rb', line 34

def store
  defined?(RequestStore) ? RequestStore.store : Thread.current
end

.trackable_class_settings(trackable_class) ⇒ Object



42
43
44
# File 'lib/mongoid/history.rb', line 42

def trackable_class_settings(trackable_class)
  trackable_settings[trackable_class.name.to_sym] || default_settings
end