lib/dry/schema/message.rb in dry-schema-0.1.1 vs lib/dry/schema/message.rb in dry-schema-0.2.0

- old
+ new

@@ -12,10 +12,12 @@ # A message sub-type used by OR operations # # @api public class Or + include Enumerable + # @api private attr_reader :left # @api private attr_reader :right @@ -32,21 +34,26 @@ @right = right @messages = messages @path = left.path end - # @api private - def hint? - false - end - # Return a string representation of the message # # @api public def to_s - [left, right].uniq.join(" #{messages[:or].()} ") + uniq.join(" #{messages[:or].()} ") end + + # @api private + def each(&block) + to_a.each(&block) + end + + # @api private + def to_a + [left, right] + end end # Build a new message object # # @api private @@ -74,30 +81,11 @@ def to_s text end # @api private - def hint? - false - end - - # @api private def eql?(other) other.is_a?(String) ? text == other : super - end - end - - # A hint message sub-type - # - # @api private - class Hint < Message - def self.[](predicate, path, text, options) - Hint.new(predicate, path, text, options) - end - - # @api private - def hint? - true end end end end