Sha256: 434394a7935ba3b5e009fd0be6cd200961d2f982210714f10f1848c3d1275de5

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module Fx
  # @api private
  module SchemaDumper
    def tables(stream)
      if Fx.configuration.dump_functions_at_beginning_of_schema
        functions(stream)
        empty_line(stream)
      end

      super

      unless Fx.configuration.dump_functions_at_beginning_of_schema
        functions(stream)
        empty_line(stream)
      end

      triggers(stream)
    end

    private

    def empty_line(stream)
      stream.puts if dumpable_functions_in_database.any?
    end

    def functions(stream)
      dumpable_functions_in_database.each do |function|
        stream.puts(function.to_schema)
      end
    end

    def triggers(stream)
      if dumpable_triggers_in_database.any?
        stream.puts
      end

      dumpable_triggers_in_database.each do |trigger|
        stream.puts(trigger.to_schema)
      end
    end

    def dumpable_functions_in_database
      @_dumpable_functions_in_database ||= Fx.database.functions
    end

    def dumpable_triggers_in_database
      @_dumpable_triggers_in_database ||= Fx.database.triggers
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fx-0.9.0 lib/fx/schema_dumper.rb