Sha256: ac3fae644b30dd577748b4be4209474b9b4289ef60f69384750d35a7bc6919a0

Contents?: true

Size: 583 Bytes

Versions: 1

Compression:

Stored size: 583 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Schema
    module Extensions
      module Hints
        module MessageSetMethods
          attr_reader :hints, :failures

          # @api private
          def initialize(messages, options = EMPTY_HASH)
            super
            @hints = messages.select(&:hint?)
            @failures = options.fetch(:failures, true)
          end

          # @api public
          def to_h
            failures ? messages_map : messages_map(hints)
          end
          alias_method :to_hash, :to_h
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-schema-0.4.0 lib/dry/schema/extensions/hints/message_set_methods.rb