Sha256: 4336af4e0b780dea11211a11f4abf989204758e39196f70d2988dafcb100656d
Contents?: true
Size: 521 Bytes
Versions: 4
Compression:
Stored size: 521 Bytes
Contents
# frozen_string_literal: true module Strict class Return class << self def make(validator = Validators::Anything.instance, coerce: false) new(validator: validator, coercer: coerce) end end attr_reader :validator, :coercer def initialize(validator:, coercer:) @validator = validator @coercer = coercer end def valid?(value) validator === value end def coerce(value) return value unless coercer coercer.call(value) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
strict-1.4.0 | lib/strict/return.rb |
strict-1.3.1 | lib/strict/return.rb |
strict-1.3.0 | lib/strict/return.rb |
strict-1.2.0 | lib/strict/return.rb |