Class: ActionDispatch::Routing::RouteWrapper
- Defined in:
- actionpack/lib/action_dispatch/routing/inspector.rb
Instance Method Summary collapse
- #action ⇒ Object
- #constraints ⇒ Object
- #controller ⇒ Object
- #endpoint ⇒ Object
- #engine? ⇒ Boolean
- #internal? ⇒ Boolean
- #json_regexp ⇒ Object
- #name ⇒ Object
- #path ⇒ Object
- #rack_app(app = self.app) ⇒ Object
- #regexp ⇒ Object
- #reqs ⇒ Object
- #verb ⇒ Object
Instance Method Details
#action ⇒ Object
67 68 69 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 67 def action requirements[:action] || ':action' end |
#constraints ⇒ Object
11 12 13 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 11 def constraints requirements.except(:controller, :action) end |
#controller ⇒ Object
63 64 65 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 63 def controller requirements[:controller] || ':controller' end |
#endpoint ⇒ Object
7 8 9 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 7 def endpoint rack_app ? rack_app.inspect : "#{controller}##{action}" end |
#engine? ⇒ Boolean
75 76 77 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 75 def engine? rack_app && rack_app.respond_to?(:routes) end |
#internal? ⇒ Boolean
71 72 73 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 71 def internal? controller.to_s =~ %r{\Arails/(info|mailers|welcome)} || path =~ %r{\A#{Rails.application.config.assets.prefix}\z} end |
#json_regexp ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 42 def json_regexp str = regexp.inspect. sub('\\A' , '^'). sub('\\Z' , '$'). sub('\\z' , '$'). sub(/^\// , ''). sub(/\/[a-z]*$/ , ''). gsub(/\(\?#.+\)/ , ''). gsub(/\(\?-\w+:/ , '('). gsub(/\s/ , '') Regexp.new(str).source end |
#name ⇒ Object
34 35 36 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 34 def name super.to_s end |
#path ⇒ Object
30 31 32 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 30 def path super.spec.to_s end |
#rack_app(app = self.app) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 15 def rack_app(app = self.app) @rack_app ||= begin class_name = app.class.name.to_s if class_name == "ActionDispatch::Routing::Mapper::Constraints" rack_app(app.app) elsif ActionDispatch::Routing::Redirect === app || class_name !~ /^ActionDispatch::Routing/ app end end end |
#regexp ⇒ Object
38 39 40 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 38 def regexp __getobj__.path.to_regexp end |
#reqs ⇒ Object
55 56 57 58 59 60 61 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 55 def reqs @reqs ||= begin reqs = endpoint reqs += " #{constraints.to_s}" unless constraints.empty? reqs end end |
#verb ⇒ Object
26 27 28 |
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 26 def verb super.source.gsub(/[$^]/, '') end |