class ArtirixDataModels::DataGateway::Error
Attributes
message[R]
method[R]
msg[R]
path[R]
response_body[R]
response_status[R]
Public Class Methods
new(*args)
click to toggle source
# File lib/artirix_data_models/gateways/data_gateway.rb, line 322 def initialize(*args) case args.size when 0 message = nil options = {} when 1 if args.first.kind_of? Hash options = args.first message = nil else message = args.first options = {} end else message = args[0] options = args[1] if message.kind_of? Hash options, message = message, options end end if message.present? options[:message] = message end build_from_options(options) if options.present? end
Public Instance Methods
data_hash()
click to toggle source
# File lib/artirix_data_models/gateways/data_gateway.rb, line 379 def data_hash { class: self.class.to_s, path: path, method: method, response_status: response_status, response_body: response_body, message: message, } end
json_response_body()
click to toggle source
# File lib/artirix_data_models/gateways/data_gateway.rb, line 351 def json_response_body return nil unless response_body.present? Oj.load response_body, symbol_keys: true rescue Oj::Error # in case it's not json nil end
matches?(other)
click to toggle source
for testing
# File lib/artirix_data_models/gateways/data_gateway.rb, line 391 def matches?(other) other.kind_of? self.class end
to_s()
click to toggle source
Calls superclass method
# File lib/artirix_data_models/gateways/data_gateway.rb, line 360 def to_s msg = super msg = nil if msg == self.class.to_s parts = { path: path, method: method, response_status: response_status, response_body: response_body, message: msg, }.select { |_, v| v.present? }.map { |k, v| "#{k}: #{v.inspect}" } "#{self.class}: #{parts.join ', '}" end
Private Instance Methods
build_from_options(path: nil, method: nil, response_status: nil, response_body: nil, message: nil, **_other)
click to toggle source
# File lib/artirix_data_models/gateways/data_gateway.rb, line 397 def build_from_options(path: nil, method: nil, response_status: nil, response_body: nil, message: nil, **_other) @path = path @method = method @response_status = response_status @response_body = response_body @message = message.presence || self.class.to_s end