Class: Simple::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/simple.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.envObject

Returns the value of attribute env.



10
11
12
# File 'lib/simple.rb', line 10

def env
  @env
end

.requestObject

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, options = {}, &blk); route(:delete, path, options, &blk); end

.get(path, options = {}, &blk) ⇒ Object



35
# File 'lib/simple.rb', line 35

def get(path, options = {}, &blk); route(:get, path, options, &blk); end

.head(path, options = {}, &blk) ⇒ Object



39
# File 'lib/simple.rb', line 39

def head(path, options = {}, &blk); route(:head, path, options, &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

.paramsObject



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, options = {}, &blk); route(:post, path, options, &blk); end

.put(path, options = {}, &blk) ⇒ Object



37
# File 'lib/simple.rb', line 37

def put(path, options = {}, &blk); route(:put, path, options, &blk); end

.reset!Object



12
13
14
# File 'lib/simple.rb', line 12

def reset!
  @namespace, @env = [], {}
end

.sessionObject



22
# File 'lib/simple.rb', line 22

def session; env['rack.session'] ||= {}; end