Sha256: 9c746e4647416379f1638dd6914d428b21e6366c24be48bbff0c6873ffb5d955
Contents?: true
Size: 511 Bytes
Versions: 2
Compression:
Stored size: 511 Bytes
Contents
# frozen_string_literal: true module Strict class Return class << self def make(validator = Validators::Anything.instance, coerce: false) new(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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
strict-1.1.0 | lib/strict/return.rb |
strict-1.0.0 | lib/strict/return.rb |