Module: EnumKit::ActiveRecordExtensions::SchemaDumper

Defined in:
lib/enum_kit/active_record_extensions/schema_dumper.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#enums(stream) ⇒ Object

Write ‘create_enum` statements for each of the enum types created in the database to the specified stream.

Parameters:

  • stream (IO)

    The stream to write the statements into.



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/enum_kit/active_record_extensions/schema_dumper.rb', line 23

def enums(stream)
  return unless @connection.respond_to?(:enums)

  statements = @connection.enums.map do |name, values|
    "  create_enum #{name.inspect}, #{values.inspect}"
  end

  return if statements.empty?

  stream.puts statements.join("\n")
  stream.puts
end

#tables(stream) ⇒ Object

:nodoc:



14
15
16
17
# File 'lib/enum_kit/active_record_extensions/schema_dumper.rb', line 14

def tables(stream)
  enums(stream)
  super
end