Sha256: 13ebb56cb14218d8453202075404f38fbbdbdadfad1dac1fd4866bfa406a08bd

Contents?: true

Size: 641 Bytes

Versions: 1

Compression:

Stored size: 641 Bytes

Contents

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?)
          end

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

          # @api private
          def failures?
            options[:failures].equal?(true)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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