lib/lotus/view/rendering/layout_scope.rb
# Forward all the missing methods to the view scope or to the layout.
#
# @api private
# @since 0.1.0
#
# @see Lotus::View::Rendering::Scope
# @see Lotus::Layout
#
# @example
#   # In the layout template:
#   #   templates/application.html.erb
#   #
#   # Use like this:
#   <title><%= article.title %></title>
#
#   # `article` will be looked up in the view scope first.
#   # If not found, it will be searched within the layout.
Forward all the missing methods to the view scope or to the layout.
Forward all the missing methods to the view scope or to the layout .
def method_missing(m, *args, &blk)
          if @scope.respond_to?(m)
            @scope.__send__(m, *args, &blk)
          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 method_missing ( m , * args , & blk ) if @scope . respond_to? ( m ) @scope . __send__ ( m , * args , & blk ) 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
Forward all the missing methods to the view scope or to the layout.
Forward all the missing methods to the view scope or to the layout .
m
args
blk
api
None
since
None
see
None
see
None
example
In the layout template: # templates/application.html.erb # Use like this: <%= article.title %> # `article` will be looked up in the view scope first. # If not found, it will be searched within the layout.
In the layout template : # templates / application . html . erb # Use like this : <% = article . title % > # ` article ` will be looked up in the view scope first . # If not found it will be searched within the layout .