Sha256: c6eec667dfe9b86fea58f18dc4a4aea19105dbfc558c69096311dd3cfdf24484

Contents?: true

Size: 857 Bytes

Versions: 10

Compression:

Stored size: 857 Bytes

Contents

module Braintree
  # See http://www.braintreepaymentsolutions.com/docs/ruby/general/validation_errors
  class Errors
    include Enumerable

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

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

    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

10 entries across 10 versions & 1 rubygems

Version Path
braintree-2.10.0 lib/braintree/errors.rb
braintree-2.9.1 lib/braintree/errors.rb
braintree-2.8.0 lib/braintree/errors.rb
braintree-2.7.0 lib/braintree/errors.rb
braintree-2.6.3 lib/braintree/errors.rb
braintree-2.6.2 lib/braintree/errors.rb
braintree-2.6.1 lib/braintree/errors.rb
braintree-2.6.0 lib/braintree/errors.rb
braintree-2.5.2 lib/braintree/errors.rb
braintree-2.5.1 lib/braintree/errors.rb