lib/dry/schema/extensions/hints/message_set_methods.rb in dry-schema-0.6.0 vs lib/dry/schema/extensions/hints/message_set_methods.rb in dry-schema-1.0.0

- old
+ new

@@ -2,19 +2,37 @@ module Dry module Schema module Extensions module Hints + # Hint extensions for MessageSet + # + # @api public module MessageSetMethods - attr_reader :hints, :failures + # Filtered message hints from all messages + # + # @return [Array<Message::Hint>] + attr_reader :hints + + # Configuration option to enable/disable showing errors + # + # @return [Boolean] + attr_reader :failures # @api private def initialize(messages, options = EMPTY_HASH) super @hints = messages.select(&:hint?) @failures = options.fetch(:failures, true) end + # Dump message set to a hash with either all messages or just hints + # + # @see MessageSet#to_h + # @see ResultMethods#hints + # + # @return [Hash<Symbol=>Array<String>>] + # # @api public def to_h @to_h ||= failures ? messages_map : messages_map(hints) end alias_method :to_hash, :to_h