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
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.
-
#msg ⇒ Object
Returns the value of attribute message.
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ Error
Returns a new instance of Error.
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 322 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)
Returns the value of attribute message.
318 319 320 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 318 def @message end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
318 319 320 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 318 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
318 319 320 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 318 def path @path end |
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
318 319 320 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 318 def response_body @response_body end |
#response_status ⇒ Object (readonly)
Returns the value of attribute response_status.
318 319 320 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 318 def response_status @response_status end |
Instance Method Details
#data_hash ⇒ Object
379 380 381 382 383 384 385 386 387 388 |
# 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: , } end |
#json_response_body ⇒ Object
351 352 353 354 355 356 357 358 |
# 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) ⇒ Boolean
for testing
391 392 393 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 391 def matches?(other) other.kind_of? self.class end |
#msg ⇒ Object
Returns the value of attribute message.
320 321 322 |
# File 'lib/artirix_data_models/gateways/data_gateway.rb', line 320 def @message end |
#to_s ⇒ Object
360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# 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 |