Sha256: ff81a9c375d8b471ed6113bd3ceee1aefa2bbdcb7483b5667dd5011439b2f4a2
Contents?: true
Size: 654 Bytes
Versions: 4
Compression:
Stored size: 654 Bytes
Contents
# frozen_string_literal: true class Shaped::Shapes::Or < 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
shaped-0.6.4 | lib/shaped/shapes/or.rb |
shaped-0.6.3 | lib/shaped/shapes/or.rb |
shaped-0.6.2 | lib/shaped/shapes/or.rb |
shaped-0.6.1 | lib/shaped/shapes/or.rb |