Sha256: 057dab0c580e471050730ce02c68dbaa2124960749c68341bfbfa0072f8660a0
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true module Vedeu module Coercers # Provides the mechanism to convert a value into another value. # # @api private # class Coercer include Vedeu::Common # @param (see #initialize) # @return (see #coerce) def self.coerce(value) new(value).coerce end # Returns a new instance of the Vedeu::Coercers::Coercer # subclass. # # @param value [void] # @return [Vedeu::Coercers::Coercer] def initialize(value) @value = value end # @macro raise_not_implemented def coerce raise Vedeu::Error::NotImplemented, 'Subclasses implement this.' end protected # @!attribute [r] value # @return [void] attr_reader :value private # @return [Boolean] def coerced? value.is_a?(klass) end # @macro raise_fatal def incoercible! raise Vedeu::Error::Fatal, "Vedeu cannot coerce a '#{value.class.name}' into a '#{klass}'." end # @macro raise_not_implemented def klass raise Vedeu::Error::NotImplemented, 'Subclasses implement this.' end end # Coercer end # Coercers end # Vedeu
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.8.17 | lib/vedeu/coercers/coercer.rb |
vedeu-0.8.16 | lib/vedeu/coercers/coercer.rb |