class Papercraft::ExtensionProxy
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.
Public Class Methods
Initializes a new ExtensionProxy
.
@param renderer [Papercraft::Renderer] renderer to proxy to @param mod [Module] extension module @return [void]
# File lib/papercraft/extension_proxy.rb, line 17 def initialize(renderer, mod) @renderer = renderer extend(mod) end
Public Instance Methods
Proxies missing methods to the renderer.
@param sym [Symbol] method name @param *args [Array] arguments @param *props [Array] named arguments @param &block [Proc] block @return void
# File lib/papercraft/extension_proxy.rb, line 29 def method_missing(sym, *args, **props, &block) @renderer.send(sym, *args, **props, &block) end
Overrides the ‘Kernel#p` method to emit a p tag.
@param *args [Array] arguments @param *props [Array] named arguments @param &block [Proc] block @return void
# File lib/papercraft/extension_proxy.rb, line 39 def p(text = nil, **props, &block) @renderer.p(text, **props, &block) end