Sha256: a6db0e8c758d4771e7fb5d189af1d92308e7007541dbb13ae35258bd8ebe185a
Contents?: true
Size: 1.42 KB
Versions: 5
Compression:
Stored size: 1.42 KB
Contents
require 'rubygems' require 'json' module RHCP class Response class Status OK="ok" ERROR="error" end # TODO these should be attr_reader's, but then we've got to solve json_create() differently attr_accessor :status attr_accessor :error_text attr_accessor :error_detail attr_accessor :data # TODO this should be called 'cookies' attr_accessor :context # textual description of the result (optional) attr_accessor :result_text attr_accessor :created_at def initialize @status = Status::OK @error_text = "" @error_detail = "" @result_text = "" @context = nil @created_at = Time.now().to_i end def mark_as_error(text, detail="") @status = Status::ERROR @error_text = text @error_detail = detail end def set_payload(data) @data = data end def set_context(new_context) @context = new_context end def as_json(options = {}) { :status => @status, :error_text => @error_text, :error_detail => @error_detail, :data => @data, # TODO what about JSONinification of data? (probably data should be JSON-ish data only, i.e. no special objects) :result_text => @result_text, :context => @context, :created_at => @created_at, :created_at_iso8601 => Time.at(@created_at).iso8601(), } end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
rhcp-0.2.21 | lib/rhcp/response.rb |
rhcp-0.2.20 | lib/rhcp/response.rb |
rhcp-0.2.19 | lib/rhcp/response.rb |
rhcp-0.2.18 | lib/rhcp/response.rb |
rhcp-0.2.17 | lib/rhcp/response.rb |