Class: Papercraft::ExtensionProxy
- Inherits:
-
Object
- Object
- Papercraft::ExtensionProxy
- Defined in:
- lib/papercraft/extension_proxy.rb
Overview
An ExtensionProxy proxies method calls to a renderer. Extension proxies are used to provide an namespaced interface to Papercraft extensions. When an extension is installed using ‘Papercraft.extension`, a corresponding method is defined on the `Papercraft::Renderer` class that creates an extension proxy that gives access to the different extension methods.
Instance Method Summary collapse
-
#initialize(renderer, mod) ⇒ void
constructor
Initializes a new ExtensionProxy.
-
#method_missing(sym, *args, **props, &block) ⇒ Object
Proxies missing methods to the renderer.
-
#p(text = nil, **props, &block) ⇒ Object
Overrides the ‘Kernel#p` method to emit a p tag.
Constructor Details
#initialize(renderer, mod) ⇒ void
Initializes a new ExtensionProxy.
17 18 19 20 |
# File 'lib/papercraft/extension_proxy.rb', line 17 def initialize(renderer, mod) @renderer = renderer extend(mod) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, **props, &block) ⇒ Object
Proxies missing methods to the renderer.
28 29 30 |
# File 'lib/papercraft/extension_proxy.rb', line 28 def method_missing(sym, *args, **props, &block) @renderer.send(sym, *args, **props, &block) end |
Instance Method Details
#p(text = nil, **props, &block) ⇒ Object
Overrides the ‘Kernel#p` method to emit a p tag.
37 38 39 |
# File 'lib/papercraft/extension_proxy.rb', line 37 def p(text = nil, **props, &block) @renderer.p(text, **props, &block) end |