Class: Slimi::Filters::Embedded Private
- Defined in:
- lib/slimi/filters/embedded.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Temple filter which processes embedded engines
Defined Under Namespace
Classes: Engine, InterpolateTiltEngine, JavaScriptEngine, RubyEngine, SassEngine, TagEngine, TiltEngine
Class Attribute Summary collapse
- .engines ⇒ Object readonly private
Class Method Summary collapse
- .create(name, options) ⇒ Object private
-
.register(name, klass, *option_filter) ⇒ Object
private
Register embedded engine.
Instance Method Summary collapse
- #enabled?(name) ⇒ Boolean private
-
#initialize(opts = {}) ⇒ Embedded
constructor
private
A new instance of Embedded.
- #on_slimi_embedded(name, body, attrs) ⇒ Object private
Methods inherited from Base
#on_slimi_control, #on_slimi_output, #on_slimi_position, #on_slimi_text
Constructor Details
#initialize(opts = {}) ⇒ Embedded
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Embedded.
99 100 101 102 103 104 |
# File 'lib/slimi/filters/embedded.rb', line 99 def initialize(opts = {}) super @engines = {} @enabled = normalize_engine_list([:enable_engines]) @disabled = normalize_engine_list([:disable_engines]) end |
Class Attribute Details
.engines ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
73 74 75 |
# File 'lib/slimi/filters/embedded.rb', line 73 def engines @engines end |
Class Method Details
.create(name, options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
91 92 93 94 |
# File 'lib/slimi/filters/embedded.rb', line 91 def create(name, ) constructor = engines[name] || raise(Temple::FilterError, "Embedded engine #{name} not found") constructor.call() end |
.register(name, klass, *option_filter) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Register embedded engine
81 82 83 84 85 86 87 88 89 |
# File 'lib/slimi/filters/embedded.rb', line 81 def register(name, klass, *option_filter) name = name.to_sym = option_filter.last.respond_to?(:to_hash) ? option_filter.pop.to_hash : {} (name, *option_filter) klass.(name) engines[name.to_sym] = proc do || klass.new({}.update().delete_if { |k, _v| !option_filter.include?(k) && k != name }.update()) end end |
Instance Method Details
#enabled?(name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
114 115 116 117 |
# File 'lib/slimi/filters/embedded.rb', line 114 def enabled?(name) (!@enabled || @enabled.include?(name)) && (!@disabled || !@disabled.include?(name)) end |
#on_slimi_embedded(name, body, attrs) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
106 107 108 109 110 111 112 |
# File 'lib/slimi/filters/embedded.rb', line 106 def (name, body, attrs) name = name.to_sym raise(Temple::FilterError, "Embedded engine #{name} is disabled") unless enabled?(name) @engines[name] ||= self.class.create(name, ) @engines[name].(name, body, attrs) end |