Class: XResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/merb-ext-direct/xresponse.rb

Overview

XResponse A standard response class suitable for Ext.Direct AJAX responses.

Author:

  • Chris Scott

Direct Known Subclasses

XExceptionResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(req) ⇒ XResponse

Returns a new instance of XResponse.



10
11
12
13
14
15
16
17
# File 'lib/merb-ext-direct/xresponse.rb', line 10

def initialize(req)
    @tid    = req.tid
    @type   = req.type
    @status = false
    @message = ''
    @result = []
    @errors = []
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



7
8
9
# File 'lib/merb-ext-direct/xresponse.rb', line 7

def errors
  @errors
end

#messageObject

Returns the value of attribute message.



7
8
9
# File 'lib/merb-ext-direct/xresponse.rb', line 7

def message
  @message
end

#resultObject

Returns the value of attribute result.



7
8
9
# File 'lib/merb-ext-direct/xresponse.rb', line 7

def result
  @result
end

#statusObject

Returns the value of attribute status.



7
8
9
# File 'lib/merb-ext-direct/xresponse.rb', line 7

def status
  @status
end

#successObject

Returns the value of attribute success.



7
8
9
# File 'lib/merb-ext-direct/xresponse.rb', line 7

def success
  @success
end

#tidObject (readonly)

Returns the value of attribute tid.



8
9
10
# File 'lib/merb-ext-direct/xresponse.rb', line 8

def tid
  @tid
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/merb-ext-direct/xresponse.rb', line 7

def type
  @type
end

Instance Method Details

#to_hObject



19
20
21
# File 'lib/merb-ext-direct/xresponse.rb', line 19

def to_h
    {:tid => @tid, :status => @status, :type => @type, :message => @message, :result => @result, :errors => @errors}
end

#to_jsonObject



23
24
25
# File 'lib/merb-ext-direct/xresponse.rb', line 23

def to_json
    self.to_h.to_json
end