Class: Simple::Base
- Inherits:
-
Object
- Object
- Simple::Base
- Defined in:
- lib/simple.rb
Class Attribute Summary collapse
-
.env ⇒ Object
Returns the value of attribute env.
-
.request ⇒ Object
Returns the value of attribute request.
Class Method Summary collapse
- .call(env) ⇒ Object
- .delete(path, options = {}, &blk) ⇒ Object
- .get(path, options = {}, &blk) ⇒ Object
- .head(path, options = {}, &blk) ⇒ Object
- .inherited(subclass) ⇒ Object
- .namespace(path, &blk) ⇒ Object (also: path, resource, resources, segment, group)
- .params ⇒ Object
- .post(path, options = {}, &blk) ⇒ Object
- .put(path, options = {}, &blk) ⇒ Object
- .reset! ⇒ Object
- .session ⇒ Object
Class Attribute Details
.env ⇒ Object
Returns the value of attribute env.
10 11 12 |
# File 'lib/simple.rb', line 10 def env @env end |
.request ⇒ Object
Returns the value of attribute request.
10 11 12 |
# File 'lib/simple.rb', line 10 def request @request end |
Class Method Details
.call(env) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/simple.rb', line 41 def call(env) @request = Rack::Request.new(env) @params = @request.params.symbolize_keys return not_found unless router.recognize(env) @env = env compile_response(env) end |
.delete(path, options = {}, &blk) ⇒ Object
38 |
# File 'lib/simple.rb', line 38 def delete(path, = {}, &blk); route(:delete, path, , &blk); end |
.get(path, options = {}, &blk) ⇒ Object
35 |
# File 'lib/simple.rb', line 35 def get(path, = {}, &blk); route(:get, path, , &blk); end |
.head(path, options = {}, &blk) ⇒ Object
39 |
# File 'lib/simple.rb', line 39 def head(path, = {}, &blk); route(:head, path, , &blk); end |
.inherited(subclass) ⇒ Object
16 17 18 19 |
# File 'lib/simple.rb', line 16 def inherited(subclass) subclass.reset! super end |
.namespace(path, &blk) ⇒ Object Also known as: path, resource, resources, segment, group
24 25 26 27 28 |
# File 'lib/simple.rb', line 24 def namespace(path, &blk) @namespace.push(path) blk.yield @namespace.pop end |
.params ⇒ Object
21 |
# File 'lib/simple.rb', line 21 def params; _params.merge(env['router.params']); end |
.post(path, options = {}, &blk) ⇒ Object
36 |
# File 'lib/simple.rb', line 36 def post(path, = {}, &blk); route(:post, path, , &blk); end |
.put(path, options = {}, &blk) ⇒ Object
37 |
# File 'lib/simple.rb', line 37 def put(path, = {}, &blk); route(:put, path, , &blk); end |
.reset! ⇒ Object
12 13 14 |
# File 'lib/simple.rb', line 12 def reset! @namespace, @env = [], {} end |
.session ⇒ Object
22 |
# File 'lib/simple.rb', line 22 def session; env['rack.session'] ||= {}; end |