Class: XResponse
- Inherits:
-
Object
- Object
- XResponse
- Defined in:
- lib/rails-extjs-direct/xresponse.rb
Overview
XResponse A standard response class suitable for Ext.Direct AJAX responses.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#message ⇒ Object
Returns the value of attribute message.
-
#result ⇒ Object
Returns the value of attribute result.
-
#status ⇒ Object
Returns the value of attribute status.
-
#success ⇒ Object
Returns the value of attribute success.
-
#tid ⇒ Object
readonly
Returns the value of attribute tid.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(req) ⇒ XResponse
constructor
A new instance of XResponse.
- #to_h ⇒ Object
- #to_json(*p) ⇒ Object
Constructor Details
#initialize(req) ⇒ XResponse
Returns a new instance of XResponse.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rails-extjs-direct/xresponse.rb', line 10 def initialize(req) if req.kind_of?(XRequest) @tid = req.tid @type = req.type else req.kind_of?(Hash) @tid = req["tid"] @type = req["type"] end @status = false @message = '' @result = [] @errors = [] end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
7 8 9 |
# File 'lib/rails-extjs-direct/xresponse.rb', line 7 def errors @errors end |
#message ⇒ Object
Returns the value of attribute message.
7 8 9 |
# File 'lib/rails-extjs-direct/xresponse.rb', line 7 def @message end |
#result ⇒ Object
Returns the value of attribute result.
7 8 9 |
# File 'lib/rails-extjs-direct/xresponse.rb', line 7 def result @result end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/rails-extjs-direct/xresponse.rb', line 7 def status @status end |
#success ⇒ Object
Returns the value of attribute success.
7 8 9 |
# File 'lib/rails-extjs-direct/xresponse.rb', line 7 def success @success end |
#tid ⇒ Object (readonly)
Returns the value of attribute tid.
8 9 10 |
# File 'lib/rails-extjs-direct/xresponse.rb', line 8 def tid @tid end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/rails-extjs-direct/xresponse.rb', line 7 def type @type end |
Instance Method Details
#to_h ⇒ Object
25 26 27 |
# File 'lib/rails-extjs-direct/xresponse.rb', line 25 def to_h {:tid => @tid, :status => @status, :type => @type, :message => @message, :result => @result, :errors => @errors} end |
#to_json(*p) ⇒ Object
29 30 31 |
# File 'lib/rails-extjs-direct/xresponse.rb', line 29 def to_json(*p) self.to_h.to_json end |