Class: Rubko::App
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#finalizers ⇒ Object
readonly
Returns the value of attribute finalizers.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#mime ⇒ Object
Returns the value of attribute mime.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#shared ⇒ Object
readonly
Returns the value of attribute shared.
-
#status ⇒ Object
Returns the value of attribute status.
Attributes included from Base
Instance Method Summary collapse
- #init(path) ⇒ Object
-
#initialize(env, shared = nil) ⇒ App
constructor
A new instance of App.
- #production? ⇒ Boolean
- #request(name = :welcome, action = nil, *path) ⇒ Object
Methods included from Base
#camelize, #finalize, #httpGet, #jsonParse, #loadController, #loadFile, #loadModel, #loadPlugin, #loadView, #method_missing, #uncamelize
Constructor Details
#initialize(env, shared = nil) ⇒ App
Returns a new instance of App.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rubko/app.rb', line 7 def initialize(env, shared = nil) @status = 200 @headers = {'Connection' => 'Keep-Alive', 'Date' => Time.now.httpdate} @mime = 'text/html' @body = '' @shared = shared @finalizers = [] @env = env params = Rack::Utils.parse_nested_query env['rack.input'].read @params = Hash[ params.map { |k, v| [ k.to_sym, v ] } ] super() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rubko::Base
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
25 26 27 |
# File 'lib/rubko/app.rb', line 25 def body @body end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
26 27 28 |
# File 'lib/rubko/app.rb', line 26 def env @env end |
#finalizers ⇒ Object (readonly)
Returns the value of attribute finalizers.
26 27 28 |
# File 'lib/rubko/app.rb', line 26 def finalizers @finalizers end |
#headers ⇒ Object
Returns the value of attribute headers.
25 26 27 |
# File 'lib/rubko/app.rb', line 25 def headers @headers end |
#mime ⇒ Object
Returns the value of attribute mime.
25 26 27 |
# File 'lib/rubko/app.rb', line 25 def mime @mime end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
26 27 28 |
# File 'lib/rubko/app.rb', line 26 def params @params end |
#shared ⇒ Object (readonly)
Returns the value of attribute shared.
26 27 28 |
# File 'lib/rubko/app.rb', line 26 def shared @shared end |
#status ⇒ Object
Returns the value of attribute status.
25 26 27 |
# File 'lib/rubko/app.rb', line 25 def status @status end |
Instance Method Details
#init(path) ⇒ Object
28 29 30 31 |
# File 'lib/rubko/app.rb', line 28 def init(path) url.path = path request( *url.newPath ) end |
#production? ⇒ Boolean
57 58 59 |
# File 'lib/rubko/app.rb', line 57 def production? ENV['RACK_ENV'] == 'production' end |
#request(name = :welcome, action = nil, *path) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rubko/app.rb', line 33 def request(name = :welcome, action = nil, *path) @controller = loadController(name) || loadController(:error404) calls = [ action ? "_#{action}" : 'index' ] calls << calls.first + '_' + url.method calls.map! { |call| if @controller.respond_to? call @body = @controller.__send__ call, *path true end } if calls.compact.empty? @body = @controller.other action, *path end # finalize request finalizers.reverse_each(&:finalize) prepareBody! prepareHeaders! [status, headers, body] end |