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_proxy) ⇒ Route

Returns a new instance of Route.



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

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

Instance Attribute Details

#handler_classObject (readonly)

Returns the value of attribute handler_class.



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

def handler_class
  @handler_class
end

#handler_proxyObject (readonly)

Returns the value of attribute handler_proxy.



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

def handler_proxy
  @handler_proxy
end

#methodObject (readonly)

Returns the value of attribute method.



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

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#run(sinatra_call) ⇒ Object

TODO: unit test this??



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

def run(sinatra_call)
  sinatra_call.request.env.tap do |env|
    env['sinatra.params']          = sinatra_call.params
    env['deas.handler_class_name'] = self.handler_class.name
    env['deas.logging'].call "  Handler: #{env['deas.handler_class_name']}"
    env['deas.logging'].call "  Params:  #{env['sinatra.params'].inspect}"
  end
  Deas::SinatraRunner.run(self.handler_class, sinatra_call)
end

#validate!Object



12
13
14
# File 'lib/deas/route.rb', line 12

def validate!
  @handler_class = @handler_proxy.handler_class
end