Class: ActiverecordCallbackLens::Renderer::ConditionTreeHtml

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord_callback_lens/renderer/html_renderer.rb

Overview

Renders a single ConditionTree node (and its descendants) as nested <ul> markup, and exposes the flat list of leaf condition names. Extracted from HtmlRenderer so the recursive tree handling is a single, testable responsibility separate from page assembly.

All names are HTML escaped via CGI.escapeHTML so values containing <, > or & cannot break the surrounding markup.

Constant Summary collapse

Tree =
Parser::ConditionTree

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ ConditionTreeHtml

Returns a new instance of ConditionTreeHtml.

Parameters:



23
24
25
# File 'lib/activerecord_callback_lens/renderer/html_renderer.rb', line 23

def initialize(node)
  @node = node
end

Instance Method Details

#namesArray<String>

Returns leaf names (predicate + method refs), depth-first.

Returns:

  • (Array<String>)

    leaf names (predicate + method refs), depth-first



33
34
35
# File 'lib/activerecord_callback_lens/renderer/html_renderer.rb', line 33

def names
  leaf_names(@node)
end

#to_htmlString

Returns nested <ul> markup for the node.

Returns:

  • (String)

    nested <ul> markup for the node



28
29
30
# File 'lib/activerecord_callback_lens/renderer/html_renderer.rb', line 28

def to_html
  render(@node)
end