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.



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

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.



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

def handler_class
  @handler_class
end

#handler_proxyObject (readonly)

Returns the value of attribute handler_proxy.



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

def handler_proxy
  @handler_proxy
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

TODO: unit test this??



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

def run(sinatra_call)
  runner = Deas::SinatraRunner.new(self.handler_class, sinatra_call)
  sinatra_call.request.env.tap do |env|
    env['deas.params'] = runner.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['deas.params'].inspect}"
  end
  runner.run
end

#validate!Object



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

def validate!
  @handler_class = @handler_proxy.handler_class
end