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
# File 'lib/braintree/errors.rb', line 5

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

Instance Method Details

#_inner_inspectObject



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

def _inner_inspect
  @errors._inner_inspect
end

#each(&block) ⇒ Object



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

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

#for(scope) ⇒ Object



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

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

#inspectObject



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

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.



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

def size
  @errors.deep_size
end