Class: Makanai::Application
- Inherits:
-
Object
- Object
- Makanai::Application
- Defined in:
- lib/makanai/application.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#router ⇒ Object
readonly
Returns the value of attribute router.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(router:) ⇒ Application
constructor
A new instance of Application.
- #run! ⇒ Object
Constructor Details
#initialize(router:) ⇒ Application
Returns a new instance of Application.
13 14 15 16 |
# File 'lib/makanai/application.rb', line 13 def initialize(router:) @router = router @config = Settings end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
18 19 20 |
# File 'lib/makanai/application.rb', line 18 def config @config end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
18 19 20 |
# File 'lib/makanai/application.rb', line 18 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
18 19 20 |
# File 'lib/makanai/application.rb', line 18 def response @response end |
#router ⇒ Object (readonly)
Returns the value of attribute router.
18 19 20 |
# File 'lib/makanai/application.rb', line 18 def router @router end |
Instance Method Details
#call(env) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/makanai/application.rb', line 29 def call(env) @request = Makanai::Request.new(env) @response = Makanai::Response.new route_result = execute_route return route_result.result if route_result.instance_of?(Response) @response.body << execute_route @response.result end |
#run! ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/makanai/application.rb', line 20 def run! app_config = config.rack_app_config handler = Rack::Handler.get(app_config[:handler]) handler.run(self, **{ Host: app_config[:host], Port: app_config[:port] }) rescue Interrupt handler.shutdown puts '==== Goodbye! :) ====' end |