Class: Emjay::Registry::LazyComponents
- Inherits:
-
Object
- Object
- Emjay::Registry::LazyComponents
- Includes:
- Enumerable
- Defined in:
- lib/emjay/registry.rb
Overview
The renderer treats Registry.components as a hash keyed by tag name.
This proxy resolves each lookup through Registry.find so components
only load when actually referenced.
Instance Method Summary collapse
Instance Method Details
#[](tag_name) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/emjay/registry.rb', line 54 def [](tag_name) component = Registry.find(tag_name) # We only reach here on render paths (never during parsing, which uses # Registry.find directly and tolerates nil). If a tag looks like MJML # but resolves to nothing, it's almost certainly a typo like # `<mj-nonesuch>` — surface it instead of silently rendering blank. if component.nil? && tag_name.to_s.start_with?("mj-") raise UnknownComponent, "Unknown MJML component #{tag_name.inspect}" end component end |
#each ⇒ Object
66 67 68 |
# File 'lib/emjay/registry.rb', line 66 def each PATHS.each_key { |tag| yield tag, Registry.find(tag) } end |
#keys ⇒ Object
70 71 72 |
# File 'lib/emjay/registry.rb', line 70 def keys PATHS.keys end |