Class: ActionJabber::Base
- Inherits:
-
Object
- Object
- ActionJabber::Base
- Defined in:
- lib/actionjabber.rb
Constant Summary collapse
- @@routes =
[]
Class Method Summary collapse
-
.request ⇒ Object
Returns the current request.
-
.route(path, opts = {}, &block) ⇒ Object
Used in the controller definition to create routes.
-
.route!(request) ⇒ Object
Called by the backend to route a request and return a response.
Class Method Details
.request ⇒ Object
Returns the current request.
21 22 23 |
# File 'lib/actionjabber.rb', line 21 def request @@request end |
.route(path, opts = {}, &block) ⇒ Object
Used in the controller definition to create routes.
route '/users' do; end
7 8 9 |
# File 'lib/actionjabber.rb', line 7 def route(path, opts = {}, &block) @@routes << [path, opts, block] end |
.route!(request) ⇒ Object
Called by the backend to route a request and return a response. Calling this manually is not recommended.
11 12 13 14 15 16 17 18 19 |
# File 'lib/actionjabber.rb', line 11 def route!(request) @@request = request @@routes.each do |route| if route.first == request.path return route.last.call break end end end |