Module: Sinatra::AdvancedRoutes::ClassMethods
- Defined in:
- lib/sinatra/advanced_routes.rb
Instance Method Summary collapse
- #each_route(&block) ⇒ Object
- #get(path, opts = {}, &block) ⇒ Object
- #route(verb, path, options = {}, &block) ⇒ Object
Instance Method Details
#each_route(&block) ⇒ Object
137 138 139 140 |
# File 'lib/sinatra/advanced_routes.rb', line 137 def each_route(&block) return enum_for(:each_route) if respond_to? :enum_for and not block routes.inject([]) { |result, (verb, list)| result.push *list.each(&block) } end |
#get(path, opts = {}, &block) ⇒ Object
116 117 118 119 120 |
# File 'lib/sinatra/advanced_routes.rb', line 116 def get(path, opts={}, &block) first_route, *other_routes = capture_routes { super } first_route.also_change(*other_routes) first_route end |
#route(verb, path, options = {}, &block) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/sinatra/advanced_routes.rb', line 122 def route(verb, path, ={}, &block) file, line = block.source_location if block.respond_to? :source_location if file.nil? files = caller_files files.delete(__FILE__) file = files.first end file &&= File.(file) route = super(verb, path, , &block) route.to_route! verb, :app => self, :file => file, :line => line, :path => path invoke_hook :advanced_route_added, route @capture_routes << route if @capture_routes route end |