Module: Sinatra::AdvancedRoutes::ClassMethods

Defined in:
lib/sinatra/advanced_routes.rb

Instance Method Summary collapse

Instance Method Details

#each_route(&block) ⇒ Object



135
136
137
138
# File 'lib/sinatra/advanced_routes.rb', line 135

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



119
120
121
122
123
# File 'lib/sinatra/advanced_routes.rb', line 119

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



125
126
127
128
129
130
131
132
133
# File 'lib/sinatra/advanced_routes.rb', line 125

def route(verb, path, options={}, &block)
  file, line = block.source_location if block.respond_to? :source_location
  file ||= caller_files.first
  route = super(verb, path, options, &block)
  route.to_route! verb, :app => self, :file => file.expand_path, :line => line, :path => path
  invoke_hook :advanced_route_added, route
  @capture_routes << route if @capture_routes
  route
end