Class: RailsLens::Providers::CallbacksProvider

Inherits:
SectionProviderBase show all
Defined in:
lib/rails_lens/providers/callbacks_provider.rb

Instance Method Summary collapse

Methods inherited from SectionProviderBase

#process, #type

Methods inherited from Base

#process, #type

Instance Method Details

#analyzer_classObject



6
7
8
# File 'lib/rails_lens/providers/callbacks_provider.rb', line 6

def analyzer_class
  Analyzers::Callbacks
end

#applicable?(model_class) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rails_lens/providers/callbacks_provider.rb', line 10

def applicable?(model_class)
  # Only applicable to non-abstract models with callbacks
  return false if model_class.abstract_class?

  # Check if model has any callbacks defined (Rails 8+ uses unified chains)
  RailsLens::Analyzers::Callbacks::CALLBACK_CHAINS.any? do |chain_name|
    chain_method = "_#{chain_name}_callbacks"
    model_class.respond_to?(chain_method) && model_class.public_send(chain_method).present?
  end
rescue StandardError
  false
end