Class: ActionDispatch::Routing::RouteWrapper
- Defined in:
- actionpack/lib/action_dispatch/routing/inspector.rb
Overview
:nodoc:
Instance Method Summary collapse
- #action ⇒ Object
- #action_source_file_and_line ⇒ Object
- #action_source_location ⇒ Object
- #constraints ⇒ Object
- #controller ⇒ Object
- #endpoint ⇒ Object
- #engine? ⇒ Boolean
- #internal? ⇒ Boolean
- #matches_filter?(filter, value) ⇒ Boolean
- #name ⇒ Object
- #path ⇒ Object
- #rack_app ⇒ Object
- #reqs ⇒ Object
- #to_h ⇒ Object
Instance Method Details
#action ⇒ Object
56 57 58 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 56 def action parts.include?(:action) ? ":action" : requirements[:action] end |
#action_source_file_and_line ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 71 def action_source_file_and_line return unless app.dispatcher? return unless controller && action controller_name = controller.to_s action_name = action.to_s return if controller_name.start_with?(":") || action_name.start_with?(":") begin controller_class = "#{controller_name.camelize}Controller".constantize method = controller_class.instance_method(action_name.to_sym) method.source_location rescue NameError, TypeError nil end end |
#action_source_location ⇒ Object
64 65 66 67 68 69 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 64 def action_source_location file, line = action_source_file_and_line return unless file "#{file}:#{line}" end |
#constraints ⇒ Object
28 29 30 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 28 def constraints requirements.except(:controller, :action) end |
#controller ⇒ Object
52 53 54 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 52 def controller parts.include?(:controller) ? ":controller" : requirements[:controller] end |
#endpoint ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 17 def endpoint case when app.dispatcher? "#{controller}##{action}" when rack_app.is_a?(Proc) "Inline handler (Proc/Lambda)" else rack_app.inspect end end |
#engine? ⇒ Boolean
88 89 90 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 88 def engine? app.engine? end |
#internal? ⇒ Boolean
60 61 62 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 60 def internal? internal end |
#matches_filter?(filter, value) ⇒ Boolean
11 12 13 14 15 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 11 def matches_filter?(filter, value) return __getobj__.path.match(value) if filter == :exact_path_match value.match?(public_send(filter)) end |
#name ⇒ Object
40 41 42 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 40 def name super.to_s end |
#path ⇒ Object
36 37 38 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 36 def path super.spec.to_s end |
#rack_app ⇒ Object
32 33 34 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 32 def rack_app app.rack_app end |
#reqs ⇒ Object
44 45 46 47 48 49 50 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 44 def reqs @reqs ||= begin reqs = endpoint reqs += " #{constraints}" unless constraints.empty? reqs end end |
#to_h ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 92 def to_h file, line = action_source_file_and_line { name: name, verb: verb, path: path, reqs: reqs, source_location: source_location, action_source_location: action_source_location, action_source_file: file, action_source_line: line } end |