Class: XRequest
- Inherits:
-
Object
- Object
- XRequest
- Defined in:
- lib/merb-ext-direct/xrequest.rb
Overview
XRequest A standard response class suitable for Ext.Direct requests.
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#tid ⇒ Object
readonly
Returns the value of attribute tid.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#arg(index) ⇒ Object
arg return a request argument at index.
-
#initialize(params) ⇒ XRequest
constructor
A new instance of XRequest.
Constructor Details
#initialize(params) ⇒ XRequest
Returns a new instance of XRequest.
9 10 11 12 13 14 15 16 17 |
# File 'lib/merb-ext-direct/xrequest.rb', line 9 def initialize(params) # TODO: simply setting @id, @params @id = (params["id"].to_i > 0) ? params["id"].to_i : (params["data"].kind_of?(Array) && (params["data"].first.kind_of?(Integer) || params["data"].first.nil?)) ? params["data"].shift: nil @tid = params["tid"] @type = params["type"] @params = (params["data"].kind_of?(Array) && params["data"].length == 1 && params["data"].first.kind_of?(Hash)) ? params["data"].first : params["data"] || [] @controller = params["xcontroller"] @action = params["xaction"] end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
7 8 9 |
# File 'lib/merb-ext-direct/xrequest.rb', line 7 def action @action end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
7 8 9 |
# File 'lib/merb-ext-direct/xrequest.rb', line 7 def controller @controller end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/merb-ext-direct/xrequest.rb', line 7 def id @id end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
7 8 9 |
# File 'lib/merb-ext-direct/xrequest.rb', line 7 def params @params end |
#tid ⇒ Object (readonly)
Returns the value of attribute tid.
7 8 9 |
# File 'lib/merb-ext-direct/xrequest.rb', line 7 def tid @tid end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/merb-ext-direct/xrequest.rb', line 7 def type @type end |
Instance Method Details
#arg(index) ⇒ Object
arg return a request argument at index. can be used to access either [] or {}
25 26 27 28 29 30 |
# File 'lib/merb-ext-direct/xrequest.rb', line 25 def arg(index) if params[index].nil? raise XException.new("Attempt to access unknown request argument '#{index.to_s}' on transaction #{@tid}") end @params[index] end |