Class: Dry::Schema::MessageSet
- Inherits:
-
Object
- Object
- Dry::Schema::MessageSet
- Includes:
- Enumerable
- Defined in:
- lib/dry/schema/message_set.rb
Overview
A set of messages used to generate errors
Constant Summary collapse
- HINT_EXCLUSION =
i( key? filled? nil? bool? str? int? float? decimal? date? date_time? time? hash? array? format? ).freeze
Instance Attribute Summary collapse
- #failures ⇒ Object readonly
- #hints ⇒ Object readonly
- #messages ⇒ Object readonly
- #options ⇒ Object readonly
- #paths ⇒ Object readonly
- #placeholders ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean private
- #failures? ⇒ Boolean private
-
#initialize(messages, options = EMPTY_HASH) ⇒ MessageSet
constructor
private
A new instance of MessageSet.
- #to_h ⇒ Object (also: #to_hash, #dump)
Constructor Details
#initialize(messages, options = EMPTY_HASH) ⇒ MessageSet
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.
Returns a new instance of MessageSet.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dry/schema/message_set.rb', line 26 def initialize(, = EMPTY_HASH) = @hints = .select(&:hint?) @failures = - hints @paths = failures.map(&:path).uniq = initialize_hints! initialize_placeholders! end |
Instance Attribute Details
#failures ⇒ Object (readonly)
18 19 20 |
# File 'lib/dry/schema/message_set.rb', line 18 def failures @failures end |
#hints ⇒ Object (readonly)
18 19 20 |
# File 'lib/dry/schema/message_set.rb', line 18 def hints @hints end |
#messages ⇒ Object (readonly)
18 19 20 |
# File 'lib/dry/schema/message_set.rb', line 18 def end |
#options ⇒ Object (readonly)
18 19 20 |
# File 'lib/dry/schema/message_set.rb', line 18 def end |
#paths ⇒ Object (readonly)
18 19 20 |
# File 'lib/dry/schema/message_set.rb', line 18 def paths @paths end |
#placeholders ⇒ Object (readonly)
18 19 20 |
# File 'lib/dry/schema/message_set.rb', line 18 def placeholders @placeholders end |
Class Method Details
.[](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.
21 22 23 |
# File 'lib/dry/schema/message_set.rb', line 21 def self.[](, = EMPTY_HASH) new(.flatten, ) end |
Instance Method Details
#each(&block) ⇒ Object
38 39 40 41 |
# File 'lib/dry/schema/message_set.rb', line 38 def each(&block) return to_enum unless block .each(&block) end |
#empty? ⇒ Boolean
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.
56 57 58 |
# File 'lib/dry/schema/message_set.rb', line 56 def empty? .empty? end |
#failures? ⇒ Boolean
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.
51 52 53 |
# File 'lib/dry/schema/message_set.rb', line 51 def failures? [:failures].equal?(true) end |
#to_h ⇒ Object Also known as: to_hash, dump
44 45 46 |
# File 'lib/dry/schema/message_set.rb', line 44 def to_h failures? ? : hints_map end |