Module: Pakada::Dispatch::Controller
- Defined in:
- lib/pakada/dispatch/controller.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #action(name, options = {}) ⇒ Object
- #actions ⇒ Object
- #finish! ⇒ Object
- #initialize(env, options = {}, &block) ⇒ Object
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
18 19 20 |
# File 'lib/pakada/dispatch/controller.rb', line 18 def @options end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
18 19 20 |
# File 'lib/pakada/dispatch/controller.rb', line 18 def params @params end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
18 19 20 |
# File 'lib/pakada/dispatch/controller.rb', line 18 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
18 19 20 |
# File 'lib/pakada/dispatch/controller.rb', line 18 def response @response end |
Class Method Details
.create(&block) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/pakada/dispatch/controller.rb', line 11 def self.create(&block) Class.new.tap {|cls| cls.send :include, self cls.class_eval &block } end |
.included(klass) ⇒ Object
7 8 9 |
# File 'lib/pakada/dispatch/controller.rb', line 7 def self.included(klass) klass.extend Pakada.safety(self::ClassMethods) end |
Instance Method Details
#action(name, options = {}) ⇒ Object
38 39 40 41 42 |
# File 'lib/pakada/dispatch/controller.rb', line 38 def action(name, = {}) aecktschn = self.class.action(name) [:response] ||= response proc { aecktschn.call request.env, } end |
#actions ⇒ Object
34 35 36 |
# File 'lib/pakada/dispatch/controller.rb', line 34 def actions self.class.actions end |
#finish! ⇒ Object
30 31 32 |
# File 'lib/pakada/dispatch/controller.rb', line 30 def finish! throw :finish end |
#initialize(env, options = {}, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/pakada/dispatch/controller.rb', line 20 def initialize(env, = {}, &block) @request = Rack::Request.new(env) @response = [:response] || Rack::Response.new @options, @params = , request.env["router.params"] (request.env["pakada.controllers"] ||= []) << self catch(:finish) { instance_eval &block } end |