module Temple::Mixins::CompiledDispatcher
@api private
Public Instance Methods
call(exp)
click to toggle source
# File lib/temple/mixins/dispatcher.rb, line 44 def call(exp) compile(exp) end
compile(exp)
click to toggle source
# File lib/temple/mixins/dispatcher.rb, line 48 def compile(exp) dispatcher(exp) end
Private Instance Methods
dispatched_methods()
click to toggle source
# File lib/temple/mixins/dispatcher.rb, line 70 def dispatched_methods re = /^on(_[a-zA-Z0-9]+)*$/ self.methods.map(&:to_s).select(&re.method(:=~)) end
dispatcher(exp)
click to toggle source
# File lib/temple/mixins/dispatcher.rb, line 54 def dispatcher(exp) replace_dispatcher(exp) end
replace_dispatcher(exp)
click to toggle source
# File lib/temple/mixins/dispatcher.rb, line 58 def replace_dispatcher(exp) tree = DispatchNode.new dispatched_methods.each do |method| method.split('_')[1..-1].inject(tree) {|node, type| node[type.to_sym] }.method = method end self.class.class_eval %Q{def dispatcher(exp) return replace_dispatcher(exp) if self.class != #{self.class} #{tree.compile.gsub("\n", "\n ")} end} dispatcher(exp) end