Sha256: fcb12248fc840f60dcdb30555a67174250c24f3238cec2ea850a5bef76eff99c

Contents?: true

Size: 653 Bytes

Versions: 1

Compression:

Stored size: 653 Bytes

Contents

# frozen_string_literal: true

module AR
  module Enum
    module SchemaDumper
      def header(stream)
        super
        enum_types(stream)
      end

      def enum_types(stream)
        list = @connection.enum_types.to_a

        stream.puts("  # These are enum types created on this database") if list.any?

        list.each do |row|
          labels = row["labels"].split(",")
          name = row["name"].to_sym

          statement = [
            "  create_enum",
            "#{name.inspect},",
            labels.inspect
          ].join(" ")

          stream.puts(statement)
        end

        stream.puts
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ar-enum-0.2.1 lib/ar/enum/schema_dumper.rb