Module: Tanuki::BaseBehavior
- Included in:
- Tanuki_Base
- Defined in:
- lib/tanuki/behavior/object_behavior.rb
Overview
Tanuki::BaseBehavior contains basic methods for a templatable object. In is included in the base framework object class.
Instance Method Summary collapse
-
#_ctx(ctx) ⇒ Object
Returns the same context as given.
-
#_has_tpl(ctx, klass, sym) ⇒ Object
Shortcut to Tanuki::Loader::has_template?.
-
#_run_tpl(ctx, obj, sym, *args, &block) ⇒ Object
Shortcut to Tanuki::Loader::run_template.
-
#method_missing(sym, *args, &block) ⇒ Object
Allows to return template blocks.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
Allows to return template blocks. E. g. returns foobar template block when foobar_view method is called.
23 24 25 26 27 28 |
# File 'lib/tanuki/behavior/object_behavior.rb', line 23 def method_missing(sym, *args, &block) if matches = sym.to_s.match(/^(.*)_view$/) return Tanuki::Loader.run_template({}, self, matches[1].to_sym, *args, &block) end super end |
Instance Method Details
#_ctx(ctx) ⇒ Object
Returns the same context as given. Used internally by templates.
18 19 20 |
# File 'lib/tanuki/behavior/object_behavior.rb', line 18 def _ctx(ctx) ctx end |
#_has_tpl(ctx, klass, sym) ⇒ Object
Shortcut to Tanuki::Loader::has_template?. Used internally by templates.
8 9 10 |
# File 'lib/tanuki/behavior/object_behavior.rb', line 8 def _has_tpl(ctx, klass, sym) Tanuki::Loader.has_template?(ctx.templates, klass, sym) end |
#_run_tpl(ctx, obj, sym, *args, &block) ⇒ Object
Shortcut to Tanuki::Loader::run_template. Used internally by templates.
13 14 15 |
# File 'lib/tanuki/behavior/object_behavior.rb', line 13 def _run_tpl(ctx, obj, sym, *args, &block) Tanuki::Loader.run_template(ctx.templates, obj, sym, *args, &block) end |