Class: HttpRouter::ArbitraryNode

Inherits:
Node
  • Object
show all
Defined in:
lib/http_router/node.rb

Instance Attribute Summary

Attributes inherited from Node

#arbitrary_node, #catchall, #linear, #lookup, #request_node, #value, #variable

Instance Method Summary collapse

Methods inherited from Node

#add, #add_arbitrary, #add_request_methods, #add_to_catchall, #add_to_linear, #initialize, #reset!

Constructor Details

This class inherits a constructor from HttpRouter::Node

Instance Method Details

#find_on_arbitrary(request, parts, action, params) ⇒ Object



222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/http_router/node.rb', line 222

def find_on_arbitrary(request, parts, action, params)
  next_node = @linear && !@linear.empty? && @linear.find { |(procs, node)| 
    params_hash = node.value ? node.value.first.hashify_params(params) : {}
    procs.all?{|p| p.call(request, params_hash)}
  }
  if next_node
    process_match(next_node.last, parts, params, request, action)
  elsif @catchall
    process_match(@catchall, parts, params, request, action)
  elsif @value
    process_match(self, parts, params, request, action)
  end
end