Module: Whodunit::TableDefinitionExtension
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/whodunit/table_definition_extension.rb
Overview
Extension for ActiveRecord::ConnectionAdapters::TableDefinition to automatically inject whodunit_stamps when creating tables.
This module monkey-patches the TableDefinition’s column creation methods to automatically add whodunit stamp columns when auto-injection is enabled.
Instance Method Summary collapse
-
#_whodunit_stamps_added ⇒ Object
-
#_whodunit_stamps_added=(value) ⇒ Object
-
#timestamps(**options) ⇒ Object
Override timestamps to trigger automatic whodunit_stamps injection.
-
#whodunit_stamps(include_deleter: :auto, creator_type: nil, updater_type: nil, deleter_type: nil) ⇒ Object
assign true tp the tracker
@_whodunit_stamps_addedbefore the reuse/call of thewhodunit_stampsflow from the Whodunit::MigrationHelpers module (see railtie.rb).
Instance Method Details
#_whodunit_stamps_added ⇒ Object
31 32 33 |
# File 'lib/whodunit/table_definition_extension.rb', line 31 def _whodunit_stamps_added @_whodunit_stamps_added end |
#_whodunit_stamps_added=(value) ⇒ Object
35 36 37 |
# File 'lib/whodunit/table_definition_extension.rb', line 35 def _whodunit_stamps_added=(value) @_whodunit_stamps_added = value end |
#timestamps(**options) ⇒ Object
Override timestamps to trigger automatic whodunit_stamps injection
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/whodunit/table_definition_extension.rb', line 40 def (**) = .dup skip = .delete(:skip_whodunit_stamps) result = super if Whodunit.auto_inject_whodunit_stamps && !_whodunit_stamps_added && !skip whodunit_stamps(include_deleter: :auto) end result end |
#whodunit_stamps(include_deleter: :auto, creator_type: nil, updater_type: nil, deleter_type: nil) ⇒ Object
assign true tp the tracker @_whodunit_stamps_added before the
reuse/call of the whodunit_stamps flow from the Whodunit::MigrationHelpers module (see railtie.rb)
55 56 57 58 |
# File 'lib/whodunit/table_definition_extension.rb', line 55 def whodunit_stamps(include_deleter: :auto, creator_type: nil, updater_type: nil, deleter_type: nil) self._whodunit_stamps_added = true self.class.whodunit_stamps(self, include_deleter:, creator_type:, updater_type:, deleter_type:) end |