Class: Caliper::RouteWrapper
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Caliper::RouteWrapper
- Defined in:
- lib/caliper/route_inspector.rb
Instance Method Summary collapse
- #action ⇒ Object
- #constraints ⇒ Object
- #controller ⇒ Object
- #endpoint ⇒ Object
- #engine? ⇒ Boolean
- #internal? ⇒ Boolean
- #name ⇒ Object
- #path ⇒ Object
- #rack_app(app = self.app) ⇒ Object
- #reqs ⇒ Object
- #verb ⇒ Object
Instance Method Details
#action ⇒ Object
55 56 57 |
# File 'lib/caliper/route_inspector.rb', line 55 def action requirements[:action] || ':action' end |
#constraints ⇒ Object
15 16 17 |
# File 'lib/caliper/route_inspector.rb', line 15 def constraints requirements.except(:controller, :action) end |
#controller ⇒ Object
51 52 53 |
# File 'lib/caliper/route_inspector.rb', line 51 def controller requirements[:controller] || ':controller' end |
#endpoint ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/caliper/route_inspector.rb', line 7 def endpoint unless rack_app "#{controller}##{action}" end # ignore rack apps for now (don't want to know about redirects) #rack_app ? rack_app.inspect : "#{controller}##{action}" end |
#engine? ⇒ Boolean
63 64 65 |
# File 'lib/caliper/route_inspector.rb', line 63 def engine? rack_app && rack_app.respond_to?(:routes) end |
#internal? ⇒ Boolean
59 60 61 |
# File 'lib/caliper/route_inspector.rb', line 59 def internal? path =~ %r{/rails/info.*|^#{::Rails.application.config.assets.prefix}} end |
#name ⇒ Object
38 39 40 |
# File 'lib/caliper/route_inspector.rb', line 38 def name super.to_s end |
#path ⇒ Object
34 35 36 |
# File 'lib/caliper/route_inspector.rb', line 34 def path super.spec.to_s end |
#rack_app(app = self.app) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/caliper/route_inspector.rb', line 19 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 |
#reqs ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/caliper/route_inspector.rb', line 42 def reqs @reqs ||= begin reqs = endpoint # commenting out for now until tested and really required #reqs += " #{constraints.to_s}" unless constraints.empty? reqs end end |
#verb ⇒ Object
30 31 32 |
# File 'lib/caliper/route_inspector.rb', line 30 def verb super.source.gsub(/[$^]/, '') end |