Sha256: d234196dd4bedfdeb8d85015bf6232df0da67c4a063b357959c9fcb5ca7dcfec

Contents?: true

Size: 742 Bytes

Versions: 9

Compression:

Stored size: 742 Bytes

Contents

module Braintree
  class Errors
    include Enumerable

    def initialize(data = {})
      @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
      "#<#{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
      @errors._inner_inspect
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
braintree-4.24.0 lib/braintree/errors.rb
braintree-4.23.0 lib/braintree/errors.rb
braintree-4.22.0 lib/braintree/errors.rb
braintree-4.21.0 lib/braintree/errors.rb
braintree-4.20.0 lib/braintree/errors.rb
braintree-4.19.0 lib/braintree/errors.rb
braintree-4.18.0 lib/braintree/errors.rb
braintree-4.17.0 lib/braintree/errors.rb
braintree-4.16.0 lib/braintree/errors.rb