Sha256: 3891724a36612a8c3e869b2c5ff45cc7a9f9c83be1d28b5a1dd5d22691ab1414

Contents?: true

Size: 556 Bytes

Versions: 7

Compression:

Stored size: 556 Bytes

Contents

# frozen_string_literal: true

module Stairwell
  module Types
    class InType
      attr_reader :value, :type

      def initialize(value, type)
        @value = value
        @type = type
      end

      def quote
        contained_values.map(&:quote).join(', ')
      end

      def valid?
        value.is_a?(Array) && contained_values.all?(&:valid?)
      end

      private

      def contained_values
        value.map do |contained|
          Object.const_get(Stairwell::TYPE_CLASSES[type]).new(contained)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
stairwell-0.6.5 lib/stairwell/types/in_type.rb
stairwell-0.6.4 lib/stairwell/types/in_type.rb
stairwell-0.6.3 lib/stairwell/types/in_type.rb
stairwell-0.6.2 lib/stairwell/types/in_type.rb
stairwell-0.6.1 lib/stairwell/types/in_type.rb
stairwell-0.6.0 lib/stairwell/types/in_type.rb
stairwell-0.5.0 lib/stairwell/types/in_type.rb