Sha256: 32bc61c18401a2835213e66c10e1b03b0719802a3f9b0ef19702731b85a6ad06

Contents?: true

Size: 655 Bytes

Versions: 3

Compression:

Stored size: 655 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 available 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

3 entries across 3 versions & 1 rubygems

Version Path
ar-enum-0.3.0 lib/ar/enum/schema_dumper.rb
ar-enum-0.2.3 lib/ar/enum/schema_dumper.rb
ar-enum-0.2.2 lib/ar/enum/schema_dumper.rb