Class: Restfulness::Application
- Inherits:
-
Object
- Object
- Restfulness::Application
- Defined in:
- lib/restfulness/application.rb
Overview
The Restulness::Application is the starting point. It’ll deal with defining the initial configuration, and handle incoming requests from rack.
Build your own Restfulness applications by inheriting from this class:
class MyApp < Restfulness::Application
routes do
scope 'api' do # scope not supported yet!
add 'journey', JourneyResource
add 'journeys', JourneyCollectionResource
end
end
end
Class Attribute Summary collapse
-
.middlewares ⇒ Object
A simple array of rack middlewares that will be applied before handling the request in Restfulness.
-
.router ⇒ Object
Returns the value of attribute router.
Class Method Summary collapse
-
.logger ⇒ Object
Quick access to the Restfulness logger.
-
.logger=(logger) ⇒ Object
Override the default Restfulness logger.
- .routes(&block) ⇒ Object
Instance Method Summary collapse
-
#call(env) ⇒ Object
Rack Handling.
- #router ⇒ Object
Class Attribute Details
.middlewares ⇒ Object
A simple array of rack middlewares that will be applied before handling the request in Restfulness.
Probably most useful for adding the ActiveDispatch::Reloader as used by Rails to reload on each request. e.g.
middlewares << ActiveDispatch::Reloader
64 65 66 |
# File 'lib/restfulness/application.rb', line 64 def middlewares @middlewares end |
.router ⇒ Object
Returns the value of attribute router.
49 50 51 |
# File 'lib/restfulness/application.rb', line 49 def router @router end |
Class Method Details
.logger ⇒ Object
Quick access to the Restfulness logger.
69 70 71 |
# File 'lib/restfulness/application.rb', line 69 def logger Restfulness.logger end |
.logger=(logger) ⇒ Object
Override the default Restfulness logger.
74 75 76 |
# File 'lib/restfulness/application.rb', line 74 def logger=(logger) Restfulness.logger = logger end |
Instance Method Details
#call(env) ⇒ Object
Rack Handling. Forward rack call to dispatcher
29 30 31 32 |
# File 'lib/restfulness/application.rb', line 29 def call(env) @app ||= build_rack_app @app.call(env) end |
#router ⇒ Object
23 24 25 |
# File 'lib/restfulness/application.rb', line 23 def router self.class.router end |