Sha256: df9d4638d2b2b6539708452cce3e8336f8d5e076c21749991aece09056bf5a00

Contents?: true

Size: 703 Bytes

Versions: 18

Compression:

Stored size: 703 Bytes

Contents

module Formotion
  module RowType
    ROW_TYPES = Formotion::RowType.constants(false).select { |constant_name| constant_name =~ /Row$/ }

    class << self
      def for(string_or_sym)
        type = string_or_sym

        if type.is_a?(Symbol) or type.is_a? String
          string = "#{type.to_s.downcase}_row".camelize
          if not const_defined? string
            raise Formotion::InvalidClassError, "Invalid RowType value #{string_or_sym}. Create a class called #{string}"
          end
          Formotion::RowType.const_get(string)
        else
          raise Formotion::InvalidClassError, "Attempted row type #{type.inspect} is not a valid RowType."
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
formotion-1.8 lib/formotion/row_type/row_type.rb
formotion-1.7 lib/formotion/row_type/row_type.rb
formotion-1.6 lib/formotion/row_type/row_type.rb
formotion-1.5.1 lib/formotion/row_type/row_type.rb
formotion-1.5.0 lib/formotion/row_type/row_type.rb
formotion-1.4.0 lib/formotion/row_type/row_type.rb
formotion-1.3.1 lib/formotion/row_type/row_type.rb
formotion-1.3 lib/formotion/row_type/row_type.rb
formotion-1.2 lib/formotion/row_type/row_type.rb
formotion-1.1.5 lib/formotion/row_type/row_type.rb
formotion-1.1.4 lib/formotion/row_type/row_type.rb
formotion-1.1.3 lib/formotion/row_type/row_type.rb
formotion-1.1.2 lib/formotion/row_type/row_type.rb
formotion-1.1.1 lib/formotion/row_type/row_type.rb
formotion-1.1 lib/formotion/row_type/row_type.rb
formotion-1.0 lib/formotion/row_type/row_type.rb
formotion-0.5.1 lib/formotion/row_type/row_type.rb
formotion-0.5 lib/formotion/row_type/row_type.rb