Class: Hibana::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/hibana/application.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.routerHibana::Router?

Returns:

  • (Hibana::Router, nil)


8
9
10
# File 'lib/hibana/application.rb', line 8

def router
  @router
end

Class Method Details

.call(env) ⇒ Array

Parameters:

  • env (Hash{String => Object})

Returns:

  • (Array)


12
13
14
# File 'lib/hibana/application.rb', line 12

def call(env)
  rack_application.call(env)
end

.middlewareObject



21
22
23
# File 'lib/hibana/application.rb', line 21

def middleware
  @middleware ||= ::Rack::Builder.new
end

.route(&block) ⇒ Object

Set routes using hanami-router DSL.



17
18
19
# File 'lib/hibana/application.rb', line 17

def route(&block)
  self.router = ::Hanami::Router.new(&block)
end

Instance Method Details

#call(env) ⇒ Array

Parameters:

  • env (Hash{String => Object})

Returns:

  • (Array)


37
38
39
40
41
42
43
# File 'lib/hibana/application.rb', line 37

def call(env)
  unless self.class.router
    raise ::Hibana::Errors::RouterNotSetError
  end

  self.class.router.call(env)
end