Sha256: e5d998c2a3bd6ef2860708e3d8e7a8ae71c86f5effcaa17035c1732e8980d027

Contents?: true

Size: 593 Bytes

Versions: 3

Compression:

Stored size: 593 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
            @to_h ||= failures ? messages_map : messages_map(hints)
          end
          alias_method :to_hash, :to_h
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dry-schema-0.6.0 lib/dry/schema/extensions/hints/message_set_methods.rb
dry-schema-0.5.1 lib/dry/schema/extensions/hints/message_set_methods.rb
dry-schema-0.5.0 lib/dry/schema/extensions/hints/message_set_methods.rb