Sha256: 2321d68ccb0c10679968a42efb67dc6b0fb677774e13c58addbd7fad590c7c2b

Contents?: true

Size: 689 Bytes

Versions: 1

Compression:

Stored size: 689 Bytes

Contents

# frozen_string_literal: true

module Vedeu

  module Coercers

    # Provides the mechanism to convert a value into a
    # {Vedeu::Models::Row}.
    #
    # @api private
    #
    class Row < Vedeu::Coercers::Coercer

      # @param value [Vedeu::Models::Row|Array<void>|void]
      # @return [Vedeu::Models::Row]
      def coerce
        if coerced?
          value

        elsif value.is_a?(Array)
          klass.new(value.compact)

        elsif value.nil?
          klass.new

        else
          klass.new([value])

        end
      end

      private

      # @return [Class]
      def klass
        Vedeu::Models::Row
      end

    end # Row

  end # Coercers

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.8.9 lib/vedeu/coercers/row.rb