Module: Dry::Schema::Extensions::Hints::MessageSetMethods

Included in:
MessageSet
Defined in:
lib/dry/schema/extensions/hints/message_set_methods.rb

Overview

Hint extensions for MessageSet

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#failuresBoolean (readonly)

Configuration option to enable/disable showing errors

Returns:

  • (Boolean)


19
20
21
# File 'lib/dry/schema/extensions/hints/message_set_methods.rb', line 19

def failures
  @failures
end

#hintsArray<Message::Hint> (readonly)

Filtered message hints from all messages

Returns:

  • (Array<Message::Hint>)


14
15
16
# File 'lib/dry/schema/extensions/hints/message_set_methods.rb', line 14

def hints
  @hints
end

Instance Method Details

#initialize(messages, options = EMPTY_HASH) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
25
26
# File 'lib/dry/schema/extensions/hints/message_set_methods.rb', line 22

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

#to_hHash<Symbol=>Array<String>> Also known as: to_hash

Dump message set to a hash with either all messages or just hints

Returns:

  • (Hash<Symbol=>Array<String>>)

See Also:



36
37
38
# File 'lib/dry/schema/extensions/hints/message_set_methods.rb', line 36

def to_h
  @to_h ||= failures ? messages_map : messages_map(hints)
end