Class: Braintree::Errors

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/braintree/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Errors

Returns a new instance of Errors.



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

def initialize(data = {})
  data = data.merge(:errors => []) unless data
  @errors = ValidationErrorCollection.new(data)
end

Instance Method Details

#_inner_inspectObject



29
30
31
# File 'lib/braintree/errors.rb', line 29

def _inner_inspect
  @errors._inner_inspect
end

#each(&block) ⇒ Object



10
11
12
# File 'lib/braintree/errors.rb', line 10

def each(&block)
  @errors.deep_errors.each(&block)
end

#for(scope) ⇒ Object



14
15
16
# File 'lib/braintree/errors.rb', line 14

def for(scope)
  @errors.for(scope)
end

#inspectObject



18
19
20
# File 'lib/braintree/errors.rb', line 18

def inspect
  "#<#{self.class} #{_inner_inspect}>"
end

#sizeObject

Returns the total number of validation errors at all levels of nesting. For example, if creating a customer with a credit card and a billing address, and each of the customer, credit card, and billing address has 1 error, this method will return 3.



25
26
27
# File 'lib/braintree/errors.rb', line 25

def size
  @errors.deep_size
end