lib/saorin/response.rb in saorin-0.4.1 vs lib/saorin/response.rb in saorin-0.5.0
- old
+ new
@@ -1,12 +1,14 @@
require 'saorin'
require 'saorin/error'
+require 'saorin/dumpable'
require 'saorin/utility'
-require 'multi_json'
module Saorin
class Response
+ include Dumpable
+
attr_accessor :version, :result, :error, :id
def initialize(options = {})
@version = options[:version] || Saorin::JSON_RPC_VERSION
@result = options[:result]
@@ -37,14 +39,9 @@
h['jsonrpc'] = @version
h['result'] = @result unless error?
h['error'] = @error if error?
h['id'] = id
h
- end
-
- def to_json(*args)
- options = Saorin::Utility.extract_options!(args)
- MultiJson.dump to_h, options
end
def self.from_hash(hash)
raise Saorin::InvalidResponse unless hash.is_a?(::Hash)
new Saorin::Utility.symbolized_keys(hash)