Module: Ext::View::Base

Defined in:
lib/ext/view.rb

Instance Method Summary collapse

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_typeObject

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

Returns:

  • (Boolean)


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