module Olelo::Routing::ClassMethods

Public Instance Methods

delete(path, patterns = {}, &block) click to toggle source
# File lib/olelo/routing.rb, line 209
def delete(path, patterns = {}, &block)
  add_route('DELETE', path, patterns, &block)
end
get(path, patterns = {}, &block) click to toggle source
# File lib/olelo/routing.rb, line 196
def get(path, patterns = {}, &block)
  add_route('GET',  path, patterns, &block)
  add_route('HEAD', path, patterns, &block)
end
patterns(patterns = nil) click to toggle source
# File lib/olelo/routing.rb, line 191
def patterns(patterns = nil)
  @patterns ||= Hash.with_indifferent_access
  patterns ? @patterns.merge!(patterns) : @patterns
end
post(path, patterns = {}, &block) click to toggle source
# File lib/olelo/routing.rb, line 205
def post(path, patterns = {}, &block)
  add_route('POST', path, patterns, &block)
end
put(path, patterns = {}, &block) click to toggle source
# File lib/olelo/routing.rb, line 201
def put(path, patterns = {}, &block)
  add_route('PUT', path, patterns, &block)
end
router() click to toggle source
# File lib/olelo/routing.rb, line 187
def router
  @router ||= {}
end

Private Instance Methods

add_route(method, path, patterns = {}, &block) click to toggle source
# File lib/olelo/routing.rb, line 215
def add_route(method, path, patterns = {}, &block)
  name = "#{method} #{path}"
  if method_defined?(name)
    redefine_method(name, &block)
  else
    define_method(name, &block)
  end
  (router[method] ||= Router.new).add(instance_method(name), path, self.patterns.merge(patterns))
end