Exception: ArtirixDataModels::DataGateway::Error
- Inherits:
-
StandardError
- Object
- StandardError
- ArtirixDataModels::DataGateway::Error
- Defined in:
- lib/artirix_data_models/gateways/data_gateway.rb
Direct Known Subclasses
Conflict, GatewayError, NotAcceptable, NotFound, ParseError, UnprocessableEntity
Instance Attribute Summary collapse
-
#message ⇒ Object
(also: #msg)
readonly
Returns the value of attribute message.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
-
#response_status ⇒ Object
readonly
Returns the value of attribute response_status.
Instance Method Summary collapse
- #data_hash ⇒ Object
-
#initialize(*args) ⇒ Error
constructor
A new instance of Error.
- #json_response_body ⇒ Object
-
#matches?(other) ⇒ Boolean
for testing.
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ Error
Returns a new instance of Error.
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 286 def initialize(*args) case args.size when 0 = nil = {} when 1 if args.first.kind_of? Hash = args.first = nil else = args.first = {} end else = args[0] = args[1] if .kind_of? Hash , = , end end if .present? [:message] = end () if .present? end |
Instance Attribute Details
#message ⇒ Object (readonly) Also known as: msg
Returns the value of attribute message.
282 283 284 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 282 def @message end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
282 283 284 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 282 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
282 283 284 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 282 def path @path end |
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
282 283 284 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 282 def response_body @response_body end |
#response_status ⇒ Object (readonly)
Returns the value of attribute response_status.
282 283 284 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 282 def response_status @response_status end |
Instance Method Details
#data_hash ⇒ Object
339 340 341 342 343 344 345 346 347 348 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 339 def data_hash { class: self.class.to_s, path: path, method: method, response_status: response_status, response_body: response_body, message: , } end |
#json_response_body ⇒ Object
315 316 317 318 319 320 321 322 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 315 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) ⇒ Boolean
for testing
351 352 353 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 351 def matches?(other) other.kind_of? self.class end |
#to_s ⇒ Object
324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 324 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: , }.select { |_, v| v.present? }.map { |k, v| "#{k}: #{v.inspect}" } "#{self.class}: #{parts.join ', '}" end |