Class: ActiverecordCallbackLens::Collector::CallbackDefinition
- Inherits:
-
Data
- Object
- Data
- ActiverecordCallbackLens::Collector::CallbackDefinition
- Defined in:
- lib/activerecord_callback_lens/collector/callback_definition.rb,
lib/activerecord_callback_lens/collector/callback_definition.rb
Overview
Reopened to add the shared formatting behaviour every renderer needs: the callback’s lifecycle name and a human-readable label for its filter. Keeping this on the domain object (rather than duplicating it across the Mermaid, Graphviz, and HTML renderers) guarantees identical output everywhere and isolates the one I/O-heavy path (proc source slicing) for focused testing.
Defined Under Namespace
Classes: ProcNodeLocator
Instance Attribute Summary collapse
-
#condition_tree ⇒ Object
readonly
Returns the value of attribute condition_tree.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#phase ⇒ Object
readonly
Returns the value of attribute phase.
-
#raw_conditions ⇒ Object
readonly
Returns the value of attribute raw_conditions.
-
#source_location ⇒ Object
readonly
Returns the value of attribute source_location.
Instance Method Summary collapse
-
#callback_name ⇒ String
The callback’s lifecycle name, e.g.
-
#filter_label(expand: false) ⇒ String
A human-readable label for the filter (Symbol, String, or Proc).
Instance Attribute Details
#condition_tree ⇒ Object (readonly)
Returns the value of attribute condition_tree
13 14 15 |
# File 'lib/activerecord_callback_lens/collector/callback_definition.rb', line 13 def condition_tree @condition_tree end |
#event ⇒ Object (readonly)
Returns the value of attribute event
13 14 15 |
# File 'lib/activerecord_callback_lens/collector/callback_definition.rb', line 13 def event @event end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter
13 14 15 |
# File 'lib/activerecord_callback_lens/collector/callback_definition.rb', line 13 def filter @filter end |
#model ⇒ Object (readonly)
Returns the value of attribute model
13 14 15 |
# File 'lib/activerecord_callback_lens/collector/callback_definition.rb', line 13 def model @model end |
#phase ⇒ Object (readonly)
Returns the value of attribute phase
13 14 15 |
# File 'lib/activerecord_callback_lens/collector/callback_definition.rb', line 13 def phase @phase end |
#raw_conditions ⇒ Object (readonly)
Returns the value of attribute raw_conditions
13 14 15 |
# File 'lib/activerecord_callback_lens/collector/callback_definition.rb', line 13 def raw_conditions @raw_conditions end |
#source_location ⇒ Object (readonly)
Returns the value of attribute source_location
13 14 15 |
# File 'lib/activerecord_callback_lens/collector/callback_definition.rb', line 13 def source_location @source_location end |
Instance Method Details
#callback_name ⇒ String
The callback’s lifecycle name, e.g. “before_save”. Centralises the string the renderers previously each rebuilt from phase + event.
33 34 35 |
# File 'lib/activerecord_callback_lens/collector/callback_definition.rb', line 33 def callback_name "#{phase}_#{event}" end |
#filter_label(expand: false) ⇒ String
A human-readable label for the filter (Symbol, String, or Proc).
Symbol/String filters render as their own text. A Proc renders as “(proc)” by default; when expand is true it renders its actual source snippet (e.g. “-> { compute_reading_time }”), falling back to “(proc)” on any I/O or parse error.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/activerecord_callback_lens/collector/callback_definition.rb', line 46 def filter_label(expand: false) case filter when Proc return "(proc)" unless proc_source || "(proc)" else filter.to_s end end |