Class: RailsLens::Analyzers::Callbacks

Inherits:
Base
  • Object
show all
Defined in:
lib/rails_lens/analyzers/callbacks.rb

Constant Summary collapse

CALLBACK_CHAINS =

ActiveRecord callback chains (Rails 8+ uses unified chains with kind attribute)

%i[
  validation
  save
  create
  update
  destroy
  commit
  rollback
  touch
  initialize
  find
].freeze
KIND_PREFIXES =

Map kinds to full callback type names

{
  before: 'before_',
  after: 'after_',
  around: 'around_'
}.freeze
INTERNAL_CALLBACK_PREFIXES =

Callbacks that commonly come from ActiveRecord internals (symbol-based)

%w[
  autosave_associated_records_for_
  around_save_collection_association
  _ensure_no_duplicate_errors
  normalize_changed_in_place_attributes
  clear_transaction_record_state
  remember_transaction_record_state
  add_to_transaction
  sync_with_transaction_state
  trigger_transactional_callbacks
].freeze
CALLBACK_ORDER =

Known callback order for formatting output

%i[
  before_validation after_validation
  before_save around_save after_save
  before_create around_create after_create
  before_update around_update after_update
  before_destroy around_destroy after_destroy
  before_commit around_commit after_commit
  before_rollback around_rollback after_rollback
  after_touch
  after_initialize after_find
].freeze

Instance Attribute Summary

Attributes inherited from Base

#model_class

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from ErrorHandling

#safe_analyze

Constructor Details

This class inherits a constructor from RailsLens::Analyzers::Base

Instance Method Details

#analyzeObject



53
54
55
56
57
58
# File 'lib/rails_lens/analyzers/callbacks.rb', line 53

def analyze
  callbacks = extract_callbacks
  return nil if callbacks.empty?

  format_callbacks(callbacks)
end