class Arbre::Element
Public Instance Methods
helper_method(name, *args, &block)
click to toggle source
In order to not pollute our templates with helpers. prefixed everywhere we want to try to distinguish helpers that are almost always used as parameters to other methods such as path helpers and not add them as elements
# File lib/arbre/patches.rb, line 91 def helper_method(name, *args, &block) if name.match /_path$/ helpers.send(name, *args, &block) elsif (const_get([name, 'engine'].join('/').classify) rescue nil) helpers.send(name, *args, &block) else current_arbre_element.add_child helpers.send(name, *args, &block) end end
method_missing(name, *args, &block)
click to toggle source
Implements the method lookup chain. When you call a method that doesn't exist, we:
1. Try to call the method on the current DOM context 2. Return an assigned variable of the same name 3. Call the method on the helper object 4. Call super
Calls superclass method
# File lib/arbre/patches.rb, line 73 def method_missing(name, *args, &block) if current_arbre_element.respond_to?(name) current_arbre_element.send name, *args, &block elsif assigns && assigns.has_key?(name.to_sym) assigns[name.to_sym] elsif helpers.respond_to?(name) helper_method(name, *args, &block) elsif route_proxy = possible_route_proxy(name) route_proxy.send(name, *args, &block) else super end end
possible_route_proxy(name)
click to toggle source
# File lib/arbre/patches.rb, line 55 def possible_route_proxy(name) if helpers.controller.class.parent && helpers.respond_to?(namespace = helpers.controller.class.parent.to_s.underscore) if (route_proxy = helpers.send(namespace)).respond_to?(name) return route_proxy end end return nil end