Module: TentD::API::Router::ClassMethods

Defined in:
lib/tentd/api/router.rb

Instance Method Summary collapse

Instance Method Details

#delete(path, opts = {}, &bk) ⇒ Object



58
# File 'lib/tentd/api/router.rb', line 58

def delete(path, opts={}, &bk)  route 'DELETE',  path, opts, &bk end

#get(path, opts = {}, &block) ⇒ Object

Defining a ‘GET` handler also automatically defines a `HEAD` handler.



51
52
53
54
# File 'lib/tentd/api/router.rb', line 51

def get(path, opts={}, &block)
  route('GET', path, opts, &block)
  route('HEAD', path, opts, &block)
end

#head(path, opts = {}, &bk) ⇒ Object



59
# File 'lib/tentd/api/router.rb', line 59

def head(path, opts={}, &bk)    route 'HEAD',    path, opts, &bk end

#mount(klass) ⇒ Object



39
40
41
# File 'lib/tentd/api/router.rb', line 39

def mount(klass)
  routes.merge_routes klass.routes.instance_variable_get("@routes")
end

#options(path, opts = {}, &bk) ⇒ Object



60
# File 'lib/tentd/api/router.rb', line 60

def options(path, opts={}, &bk) route 'OPTIONS', path, opts, &bk end

#patch(path, opts = {}, &bk) ⇒ Object



61
# File 'lib/tentd/api/router.rb', line 61

def patch(path, opts={}, &bk)   route 'PATCH',   path, opts, &bk end

#post(path, opts = {}, &bk) ⇒ Object



57
# File 'lib/tentd/api/router.rb', line 57

def post(path, opts={}, &bk)    route 'POST',    path, opts, &bk end

#put(path, opts = {}, &bk) ⇒ Object



56
# File 'lib/tentd/api/router.rb', line 56

def put(path, opts={}, &bk)     route 'PUT',     path, opts, &bk end

#routesObject



43
44
45
# File 'lib/tentd/api/router.rb', line 43

def routes
  @routes ||= Rack::Mount::RouteSet.new
end