Class: Gakubuchi::TemplateEngine
- Inherits:
-
Object
- Object
- Gakubuchi::TemplateEngine
- Extended by:
- Forwardable
- Defined in:
- lib/gakubuchi/template_engine.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
(also: #engine)
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
-
#initialize(engine) ⇒ TemplateEngine
constructor
A new instance of TemplateEngine.
- #register!(extname) ⇒ Object
- #registered?(extname) ⇒ Boolean
Constructor Details
#initialize(engine) ⇒ TemplateEngine
Returns a new instance of TemplateEngine.
12 13 14 |
# File 'lib/gakubuchi/template_engine.rb', line 12 def initialize(engine) @klass = engine.to_s.constantize rescue nil end |
Instance Attribute Details
#klass ⇒ Object (readonly) Also known as: engine
Returns the value of attribute klass.
5 6 7 |
# File 'lib/gakubuchi/template_engine.rb', line 5 def klass @klass end |
Instance Method Details
#register!(extname) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/gakubuchi/template_engine.rb', line 16 def register!(extname) if engine.instance_of?(Class) && !registered?(extname) !!assets.register_engine(extname, engine) else false end end |
#registered?(extname) ⇒ Boolean
24 25 26 27 |
# File 'lib/gakubuchi/template_engine.rb', line 24 def registered?(extname) ext = normalize_extension(extname) assets.engines.has_key?(ext) && assets.engines[ext] == engine end |