Sha256: 28593bbcbc362ec59ff8652b38ea162849af038cc2521b2033dcc979cab97312
Contents?: true
Size: 655 Bytes
Versions: 13
Compression:
Stored size: 655 Bytes
Contents
# frozen_string_literal: true class Shaped::Shapes::Any < Shaped::Shape def initialize(*shape_descriptions) validation_options = shape_descriptions.extract_options! if shape_descriptions.size <= 1 raise(Shaped::InvalidShapeDescription, <<~ERROR.squish) A #{self.class} description must be a list of two or more shape descriptions. ERROR end @shapes = shape_descriptions.map do |description| Shaped::Shape(description, validation_options) end end def matched_by?(object) @shapes.any? { |shape| shape.matched_by?(object) } end def to_s @shapes.map(&:to_s).join(' OR ') end end
Version data entries
13 entries across 13 versions & 1 rubygems