Sha256: 0d338c477de2d45c41aee111aa727a35fdf3b6e65b49fc0ccf5c221ba432a3fe

Contents?: true

Size: 742 Bytes

Versions: 2

Compression:

Stored size: 742 Bytes

Contents

###
# XResponse
# A standard response class suitable for Ext.Direct AJAX responses.
# @author Chris Scott
#
class XResponse
    attr_accessor :type, :status, :errors, :success, :message, :result
    attr_reader :tid

    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

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

    def to_json(*p)
        self.to_h.to_json
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails-extjs-direct-0.0.15 lib/rails-extjs-direct/xresponse.rb
rails-extjs-direct-0.0.14 lib/rails-extjs-direct/xresponse.rb