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
-
#timestamps(**options) ⇒ Object
Override timestamps to trigger automatic whodunit_stamps injection.
-
#whodunit_stamps(**options) ⇒ Object
Also override whodunit_stamps to track that they’ve been added.
Instance Method Details
#timestamps(**options) ⇒ Object
Override timestamps to trigger automatic whodunit_stamps injection
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/whodunit/table_definition_extension.rb', line 37 def (**) result = super # Auto-inject whodunit_stamps after timestamps if enabled and not already added if Whodunit.auto_inject_whodunit_stamps && !@_whodunit_stamps_added && ![:skip_whodunit_stamps] whodunit_stamps(include_deleter: :auto) @_whodunit_stamps_added = true end result end |
#whodunit_stamps(**options) ⇒ Object
Also override whodunit_stamps to track that they’ve been added
52 53 54 55 |
# File 'lib/whodunit/table_definition_extension.rb', line 52 def whodunit_stamps(**) @_whodunit_stamps_added = true super end |