Sha256: 1acddacf83d2a8bfb7c6d1a6b865c87ab93e327dc642e45e1a6dd2397b112c63

Contents?: true

Size: 879 Bytes

Versions: 9

Compression:

Stored size: 879 Bytes

Contents

module Braintree
  # Provides access to errors from an ErrorResult.
  class Errors
    include Enumerable

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

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

    # Accesses validation errors for the given +scope+.
    def for(scope)
      @errors.for(scope)
    end

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

    # 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.
    def size
      @errors.deep_size
    end

    def _inner_inspect # :nodoc:
      @errors._inner_inspect
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
braintree-2.4.0 lib/braintree/errors.rb
braintree-2.3.1 lib/braintree/errors.rb
braintree-2.2.0 lib/braintree/errors.rb
braintree-2.1.0 lib/braintree/errors.rb
braintree-2.0.0 lib/braintree/errors.rb
braintree-1.2.1 lib/braintree/errors.rb
braintree-1.2.0 lib/braintree/errors.rb
braintree-1.1.3 lib/braintree/errors.rb
braintree-1.1.2 lib/braintree/errors.rb