Sha256: 16d338d310118e21cfe895894669fd3fa70ba5f83c9071adeff0e8d6f5c82428

Contents?: true

Size: 630 Bytes

Versions: 3

Compression:

Stored size: 630 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

      # @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

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.8.13 lib/vedeu/coercers/row.rb
vedeu-0.8.12 lib/vedeu/coercers/row.rb
vedeu-0.8.10 lib/vedeu/coercers/row.rb