Class: Deas::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/deas/route.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, path, handler_proxies) ⇒ Route

Returns a new instance of Route.



9
10
11
# File 'lib/deas/route.rb', line 9

def initialize(method, path, handler_proxies)
  @method, @path, @handler_proxies = method, path, handler_proxies
end

Instance Attribute Details

#handler_proxiesObject (readonly)

Returns the value of attribute handler_proxies.



7
8
9
# File 'lib/deas/route.rb', line 7

def handler_proxies
  @handler_proxies
end

#methodObject (readonly)

Returns the value of attribute method.



7
8
9
# File 'lib/deas/route.rb', line 7

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/deas/route.rb', line 7

def path
  @path
end

Instance Method Details

#run(sinatra_call) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/deas/route.rb', line 19

def run(sinatra_call)
  type = sinatra_call.settings.router.request_type_name(sinatra_call.request)
  proxy = begin
    @handler_proxies[type]
  rescue HandlerProxyNotFound
    sinatra_call.halt(404)
  end
  proxy.run(sinatra_call)
end

#validate!Object



13
14
15
16
17
# File 'lib/deas/route.rb', line 13

def validate!
  @handler_proxies.each do |request_type_name, proxy|
    proxy.validate!
  end
end