Sha256: b4aa60bc7d153c5b8c7904c6ae3c79d34151b863ce60c96552866ad5d2e58f33

Contents?: true

Size: 849 Bytes

Versions: 41

Compression:

Stored size: 849 Bytes

Contents

module Braintree
  # See http://www.braintreepayments.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

41 entries across 41 versions & 1 rubygems

Version Path
braintree-2.40.0 lib/braintree/errors.rb
braintree-2.39.0 lib/braintree/errors.rb
braintree-2.38.0 lib/braintree/errors.rb
braintree-2.37.0 lib/braintree/errors.rb
braintree-2.36.0 lib/braintree/errors.rb
braintree-2.35.0 lib/braintree/errors.rb
braintree-2.34.1 lib/braintree/errors.rb
braintree-2.34.0 lib/braintree/errors.rb
braintree-2.33.1 lib/braintree/errors.rb
braintree-2.33.0 lib/braintree/errors.rb
braintree-2.32.1 lib/braintree/errors.rb
braintree-2.31.0 lib/braintree/errors.rb
braintree-2.30.2 lib/braintree/errors.rb
braintree-2.30.0 lib/braintree/errors.rb
braintree-2.29.0 lib/braintree/errors.rb
braintree-2.28.0 lib/braintree/errors.rb
braintree-2.27.1 lib/braintree/errors.rb
braintree-2.27.0 lib/braintree/errors.rb
braintree-2.26.0 lib/braintree/errors.rb
braintree-2.25.0 lib/braintree/errors.rb