Class: Rivulet::Application
- Inherits:
-
Object
- Object
- Rivulet::Application
- Includes:
- Dry::Configurable
- Defined in:
- lib/rivulet/application.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
Returns the value of attribute db.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #migrate! ⇒ Object
- #print_routes ⇒ Object
- #routes ⇒ Object
- #run_console ⇒ Object
- #startup ⇒ Object
Instance Attribute Details
#db ⇒ Object
Returns the value of attribute db.
13 14 15 |
# File 'lib/rivulet/application.rb', line 13 def db @db end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rivulet/application.rb', line 15 def call(env) result = with_telemetry do dispatch_request.(resource: self, env: env) end return result.success[:response] if result.success? case result in Failure[:route_not_found] [404, { 'Content-Type' => 'text/plain' }, ['Not Found']] in Failure[:wrong_response_type, ] logger.error() [500, {}, []] in Failure[:conflicting_response, ] logger.error() [500, {}, []] in Failure[:file_not_found, ] logger.error() [500, {}, []] end end |
#migrate! ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/rivulet/application.rb', line 50 def migrate! result = migrate_operation.(resource: self) if result.failure? warn "Migration failed: #{result.failure}" exit 1 end end |
#print_routes ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/rivulet/application.rb', line 66 def print_routes result = print_routes_operation.(resource: self) if result.failure? warn "Cannot print routes: #{result.failure}" exit 1 end end |
#routes ⇒ Object
37 38 39 |
# File 'lib/rivulet/application.rb', line 37 def routes @routes ||= Routing::Mapper.new([]) end |
#run_console ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/rivulet/application.rb', line 58 def run_console result = run_console_operation.(resource: self) if result.failure? warn "Cannot start console: #{result.failure}" exit 1 end end |
#startup ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/rivulet/application.rb', line 41 def startup result = startup_operation.(resource: self) if result.failure? warn "Startup failed: #{result.failure}" exit 1 end self end |