Module: Ext::View::Base
- Defined in:
- lib/ext/view.rb
Instance Method Summary collapse
-
#content_type ⇒ Object
Shortcut for @headers || ‘text/html’.
-
#markaby_view?(v) ⇒ Boolean
(also: #has_view?)
Returns true if markaby provides this view.
-
#method_missing(*a, &b) ⇒ Object
Re-defined render.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*a, &b) ⇒ Object
Re-defined render
The method_missing method is great but it ties the system too much to markaby. It makes also harder to debunk wrong methods since the call- stack is longer. Finally, it encourages to put the view in the controller, which is considered bad in MVC style (that’s what ppl say)
Render is a method that gets the view and puts a layout around it if found.
Layout was renamed to _layout because it is a partial. Also partials don’t use the layout feature (so layout doesn’t have a layout)
50 51 52 53 54 55 56 |
# File 'lib/ext/view.rb', line 50 def method_missing(*a,&b) a.shift if a[0]==:render m=app::Mab.new({},self) s=m.capture{send(*a,&b)} s=m.layout{s} if m.respond_to?:layout and a[0].to_s[0] != ?_ s end |
Instance Method Details
#content_type ⇒ Object
Shortcut for @headers || ‘text/html’
93 |
# File 'lib/ext/view.rb', line 93 def content_type; @headers['Content-Type'] || 'text/html' end |
#markaby_view?(v) ⇒ Boolean Also known as: has_view?
Returns true if markaby provides this view
82 83 84 |
# File 'lib/ext/view.rb', line 82 def markaby_view?(v) app::Views.method_defined? v # this is specific to markaby end |