Module: CallbackLensRakeHelpers
- Defined in:
- lib/activerecord_callback_lens/tasks/callback_lens_helpers.rb
Overview
Helpers backing the callback_lens Rake tasks. Extracted into a plain Ruby module (rather than task-local methods) so the logic is namespaced and unit testable without loading Rake or invoking a task.
Class Method Summary collapse
-
.render_mermaid(model_class) ⇒ String
Runs the full pipeline (collect -> parse -> build -> render) for a model.
-
.resolve_model!(name) ⇒ Class
Resolves an ActiveRecord model class from its name, raising a descriptive error when MODEL is missing or the constant cannot be found.
Class Method Details
.render_mermaid(model_class) ⇒ String
Runs the full pipeline (collect -> parse -> build -> render) for a model.
29 30 31 32 33 34 |
# File 'lib/activerecord_callback_lens/tasks/callback_lens_helpers.rb', line 29 def render_mermaid(model_class) definitions = ActiverecordCallbackLens::Collector::CallbackCollector.collect(model_class) definitions = definitions.map { |definition| ActiverecordCallbackLens::Parser::ConditionParser.parse(definition) } graph = ActiverecordCallbackLens::Graph::GraphBuilder.build(definitions) ActiverecordCallbackLens::Renderer::MermaidRenderer.render(graph) end |
.resolve_model!(name) ⇒ Class
Resolves an ActiveRecord model class from its name, raising a descriptive error when MODEL is missing or the constant cannot be found.
17 18 19 20 21 22 23 |
# File 'lib/activerecord_callback_lens/tasks/callback_lens_helpers.rb', line 17 def resolve_model!(name) raise "MODEL is required. Usage: rake callback_lens:analyze MODEL=User" if name.nil? || name.empty? Object.const_get(name) rescue NameError raise "Cannot find model class '#{name}'. Make sure it is loaded." end |