Module: BigBand::Integration::YARD::Handlers::Sinatra::AbstractRouteHandler

Included in:
Legacy::RouteHandler, RouteHandler
Defined in:
lib/big_band/integration/yard.rb

Overview

Logic both handlers have in common.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.routesObject



35
36
37
# File 'lib/big_band/integration/yard.rb', line 35

def self.routes
  @routes ||= []
end

Instance Method Details

#processObject



39
40
41
42
43
44
# File 'lib/big_band/integration/yard.rb', line 39

def process
  path = http_path
  path = $1 if path =~ /^"(.*)"$/
  register_route(http_verb, path)
  register_route('HEAD', path) if http_verb == 'GET'
end

#register_route(verb, path, doc = nil) {|route| ... } ⇒ Object

Yields:

  • (route)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/big_band/integration/yard.rb', line 46

def register_route(verb, path, doc = nil)
  # HACK: Removing some illegal letters.
  method_name = "" << verb << "_" << path.gsub(/[^\w_]/, "_")
  real_name   = "" << verb << " " << path
  route = register CodeObjects::RouteObject.new(namespace, method_name, :instance) do |o|
    o.visibility = "public"
    o.source     = statement.source
    o.signature  = real_name
    o.explicit   = true
    o.scope      = scope
    o.docstring  = statement.comments
    o.http_verb  = verb
    o.http_path  = path
    o.real_name  = real_name
    o.add_file(parser.file, statement.line)
  end
  AbstractRouteHandler.routes << route
  yield(route) if block_given?
end