lib/lotus/view/rendering/layout_scope.rb in lotus-view-0.3.0 vs lib/lotus/view/rendering/layout_scope.rb in lotus-view-0.4.0

- old
+ new

@@ -31,12 +31,12 @@ # @return [String] inspect String (contains classname, objectid in hex, available ivars) # # @since 0.3.0 def inspect base = "#<#{ self.class }:#{'%x' % (self.object_id << 1)}" - base << " @layout=\"#{@layout}\"" if @layout - base << " @scope=\"#{@scope}\"" if @scope + base << " @layout=\"#{@layout.inspect}\"" if @layout + base << " @scope=\"#{@scope.inspect}\"" if @scope base << ">" end # Render a partial or a template within a layout template. # @@ -152,14 +152,18 @@ # <title><%= article.title %></title> # # # `article` will be looked up in the view scope first. # # If not found, it will be searched within the layout. def method_missing(m, *args, &blk) - begin + if @scope.respond_to?(m) @scope.__send__(m, *args, &blk) - rescue + elsif @layout.respond_to?(m) @layout.__send__(m, *args, &blk) + else + super end + rescue ::NameError + ::Kernel.raise ::NoMethodError.new("undefined method `#{ m }' for #{ self.inspect }", m) end def renderer(options) if options[:partial] Rendering::Partial