Class: Jun::ActionDispatch::Routing::Route
- Defined in:
- lib/jun/action_dispatch/routing/route_set.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#method ⇒ Object
Returns the value of attribute method.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #controller_class ⇒ Object
- #dispatch(request) ⇒ Object
- #match?(request) ⇒ Boolean
- #path_regex ⇒ Object
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action
8 9 10 |
# File 'lib/jun/action_dispatch/routing/route_set.rb', line 8 def action @action end |
#controller ⇒ Object
Returns the value of attribute controller
8 9 10 |
# File 'lib/jun/action_dispatch/routing/route_set.rb', line 8 def controller @controller end |
#method ⇒ Object
Returns the value of attribute method
8 9 10 |
# File 'lib/jun/action_dispatch/routing/route_set.rb', line 8 def method @method end |
#name ⇒ Object
Returns the value of attribute name
8 9 10 |
# File 'lib/jun/action_dispatch/routing/route_set.rb', line 8 def name @name end |
#path ⇒ Object
Returns the value of attribute path
8 9 10 |
# File 'lib/jun/action_dispatch/routing/route_set.rb', line 8 def path @path end |
Instance Method Details
#controller_class ⇒ Object
21 22 23 24 |
# File 'lib/jun/action_dispatch/routing/route_set.rb', line 21 def controller_class class_name = "#{controller.camelize}Controller" Object.const_get(class_name) end |
#dispatch(request) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/jun/action_dispatch/routing/route_set.rb', line 13 def dispatch(request) controller = controller_class.new controller.request = request controller.response = Rack::Response.new controller.handle_response(action) controller.response.finish end |
#match?(request) ⇒ Boolean
9 10 11 |
# File 'lib/jun/action_dispatch/routing/route_set.rb', line 9 def match?(request) request.request_method == method && path_regex.match?(request.path_info) end |
#path_regex ⇒ Object
26 27 28 29 |
# File 'lib/jun/action_dispatch/routing/route_set.rb', line 26 def path_regex path_string_for_regex = path.gsub(/:\w+/) { |match| "(?<#{match.delete(":")}>\\w+)" } Regexp.new("^#{path_string_for_regex}\/?$") end |