Class: Jellyfish::Controller
- Inherits:
-
Object
- Object
- Jellyfish::Controller
show all
- Includes:
- Jellyfish
- Defined in:
- lib/jellyfish.rb
Overview
Constant Summary
Constants included
from Jellyfish
LOCATION, PATH_INFO, RACK_ERRORS, REQUEST_METHOD, VERSION
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Jellyfish
#controller, #protect
Constructor Details
#initialize(routes) ⇒ Controller
Returns a new instance of Controller.
38
39
40
|
# File 'lib/jellyfish.rb', line 38
def initialize routes
@routes = routes
end
|
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
37
38
39
|
# File 'lib/jellyfish.rb', line 37
def env
@env
end
|
#routes ⇒ Object
Returns the value of attribute routes.
37
38
39
|
# File 'lib/jellyfish.rb', line 37
def routes
@routes
end
|
Instance Method Details
#block_call(argument, block) ⇒ Object
47
48
49
50
51
|
# File 'lib/jellyfish.rb', line 47
def block_call argument, block
ret = instance_exec(argument, &block)
body ret if body.nil?
[status || 200, || {}, body]
end
|
#body(value = nil) ⇒ Object
72
73
74
75
76
77
78
79
80
|
# File 'lib/jellyfish.rb', line 72
def body value=nil
if value.nil?
@body
elsif value.respond_to?(:each)
@body = value
else
@body = [value]
end
end
|
#call(env) ⇒ Object
42
43
44
45
|
# File 'lib/jellyfish.rb', line 42
def call env
@env = env
block_call(*dispatch)
end
|
#forward ⇒ Object
53
|
# File 'lib/jellyfish.rb', line 53
def forward ; raise(NotFound.new) ; end
|
#found(url) ⇒ Object
Also known as:
redirect
54
|
# File 'lib/jellyfish.rb', line 54
def found url; raise(Found.new(url)); end
|
82
83
84
85
86
87
88
|
# File 'lib/jellyfish.rb', line 82
def value
if .nil?
(value)
else
(.merge(value))
end
end
|
#path_info ⇒ Object
57
|
# File 'lib/jellyfish.rb', line 57
def path_info ; env[PATH_INFO] || '/' ; end
|
#request_method ⇒ Object
58
|
# File 'lib/jellyfish.rb', line 58
def request_method; env[REQUEST_METHOD] || 'GET'; end
|