Class: Yaframework::Base
- Inherits:
-
Object
show all
- Includes:
- Render
- Defined in:
- lib/yaframework/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Render
#partial, #render, #setup, #template_path, #view
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
14
15
16
17
18
19
20
|
# File 'lib/yaframework/base.rb', line 14
def initialize
@routes = Hash.new([])
@before_hooks = []
@after_hooks = []
@settings = {}
@inbox = {}
end
|
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
10
11
12
|
# File 'lib/yaframework/base.rb', line 10
def env
@env
end
|
#request ⇒ Object
Also known as:
req
Returns the value of attribute request.
10
11
12
|
# File 'lib/yaframework/base.rb', line 10
def request
@request
end
|
#response ⇒ Object
Also known as:
res
Returns the value of attribute response.
10
11
12
|
# File 'lib/yaframework/base.rb', line 10
def response
@response
end
|
#routes ⇒ Object
Returns the value of attribute routes.
10
11
12
|
# File 'lib/yaframework/base.rb', line 10
def routes
@routes
end
|
#settings ⇒ Object
Returns the value of attribute settings.
10
11
12
|
# File 'lib/yaframework/base.rb', line 10
def settings
@settings
end
|
Instance Method Details
#after(&block) ⇒ Object
51
52
53
|
# File 'lib/yaframework/base.rb', line 51
def after(&block)
@after_hooks << block
end
|
#before(&block) ⇒ Object
47
48
49
|
# File 'lib/yaframework/base.rb', line 47
def before(&block)
@before_hooks << block
end
|
32
33
34
|
# File 'lib/yaframework/base.rb', line 32
def configure(&block)
exec(block) if block_given?
end
|
#halt(response) ⇒ Object
43
44
45
|
# File 'lib/yaframework/base.rb', line 43
def halt(response)
throw :halt, response
end
|
#handle(status, &block) ⇒ Object
59
60
61
|
# File 'lib/yaframework/base.rb', line 59
def handle(status, &block)
@inbox[status] = block
end
|
#helpers(&block) ⇒ Object
28
29
30
|
# File 'lib/yaframework/base.rb', line 28
def helpers(&block)
exec(block) if block_given?
end
|
#listen(port = 5000) ⇒ Object
63
64
65
|
# File 'lib/yaframework/base.rb', line 63
def listen(port = 5000)
Rack::Handler::WEBrick.run self, Port: port
end
|
#params ⇒ Object
55
56
57
|
# File 'lib/yaframework/base.rb', line 55
def params
request.params
end
|