Class: Metanorma::Html::BaseRenderer::RendererContext
- Inherits:
-
Object
- Object
- Metanorma::Html::BaseRenderer::RendererContext
- Defined in:
- lib/metanorma/html/base_renderer.rb
Overview
Facade object for Drops to call renderer methods without exposing the full private interface. Delegates via method_missing with an explicit allowlist — adding new delegations only requires updating DELEGATED_METHODS, not writing a new one-liner.
Constant Summary collapse
- DELEGATED_METHODS =
%i[ safe_attr escape_html extract_block_label extract_plain_text capture_output render_paragraph render_mixed_inline render_inline_element render_unordered_list render_ordered_list render_definition_list render_sourcecode render_table render_figure render_quote render_formula render_note render_image render_stem_content register_figure_entry render_liquid render_block_children ].freeze
Instance Method Summary collapse
-
#initialize(renderer) ⇒ RendererContext
constructor
A new instance of RendererContext.
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(renderer) ⇒ RendererContext
Returns a new instance of RendererContext.
95 96 97 |
# File 'lib/metanorma/html/base_renderer.rb', line 95 def initialize(renderer) @renderer = renderer end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object (private)
105 106 107 108 109 110 111 |
# File 'lib/metanorma/html/base_renderer.rb', line 105 def method_missing(method_name, ...) if DELEGATED_METHODS.include?(method_name) @renderer.public_send(method_name, ...) else super end end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
99 100 101 |
# File 'lib/metanorma/html/base_renderer.rb', line 99 def respond_to_missing?(method_name, include_private = false) DELEGATED_METHODS.include?(method_name) || super end |