Sha256: cce0f7eb07b309eca2345fab69ef39c4cbfc634d0d8b3840e0fb1d6769e09d01
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 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 # @return [void] def coerce fail 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 # @return [void] def incoercible! fail Vedeu::Error::Fatal, "Vedeu cannot coerce a '#{value.class.name}' into a " \ "'#{klass}'." end # @macro raise_not_implemented # @return [Class] def klass fail 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.12 | lib/vedeu/coercers/coercer.rb |
vedeu-0.8.10 | lib/vedeu/coercers/coercer.rb |