Class: Braintree::ValidationError

Inherits:
Object
  • Object
show all
Includes:
BaseModule
Defined in:
lib/braintree/validation_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseModule

included

Methods included from BaseModule::Methods

#copy_instance_variables_from_object, #return_object_or_raise, #set_instance_variables_from_hash, #singleton_class

Constructor Details

#initialize(error_hash) ⇒ ValidationError

Returns a new instance of ValidationError.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/braintree/validation_error.rb', line 9

def initialize(error_hash)
  # parse GraphQL response objects
  if (error_hash[:extensions] &&
      error_hash[:extensions][:errorClass] &&
      error_hash[:extensions][:errorClass] == "VALIDATION")
    error_hash[:code] = error_hash[:extensions][:legacyCode].to_i
    error_hash[:attribute] = error_hash[:path].last
  end

  set_instance_variables_from_hash error_hash
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



5
6
7
# File 'lib/braintree/validation_error.rb', line 5

def attribute
  @attribute
end

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/braintree/validation_error.rb', line 6

def code
  @code
end

#messageObject (readonly)

Returns the value of attribute message.



7
8
9
# File 'lib/braintree/validation_error.rb', line 7

def message
  @message
end

Instance Method Details

#inspectObject



21
22
23
# File 'lib/braintree/validation_error.rb', line 21

def inspect
  "#<#{self.class} (#{code}) #{message}>"
end