Sha256: afbfff7b4fd32cf3a391436ca0d69c1dc591f994c690a1be50978cbfe56501a9

Contents?: true

Size: 887 Bytes

Versions: 1

Compression:

Stored size: 887 Bytes

Contents

module ActiveRecord
  module PGEnum
    module SchemaDumper
      private

      def extensions(stream)
        super
        enums(stream)
      end

      def enums(stream)
        return unless (enum_types = @connection.enum_types).any?

        stream.puts "  # These are custom enum types that must be created before they can be used in the schema definition"

        enum_types.each do |name, definition|
          stream.puts %Q{  create_enum "#{name}", %w[#{definition.join(" ")}]}
        end

        stream.puts
      end

      # Takes a column specification in Object form and serializes it into a String.
      def format_colspec(colspec)
        case colspec
        when String
          colspec
        when Array
          colspec.map { |value| format_colspec(value) }.select(&:present?).join(", ")
        else
          super
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-pg_enum-0.3.0 lib/active_record/pg_enum/4.2/schema_dumper.rb