Sha256: cee9f6910679c6207b9195ffe674c3f5d177aaacfd6fb4de30c52713f3bfc897

Contents?: true

Size: 831 Bytes

Versions: 62

Compression:

Stored size: 831 Bytes

Contents

# frozen_string_literal: true

require_relative 'base'

module DeclareSchema
  module SchemaChange
    class Base
      class << self
        def format_options(options)
          options.map do |k, v|
            value =
              if v.is_a?(Hash)
                "{ #{format_options(v).join(', ')} }"
              else
                v.inspect
              end
            if k.is_a?(Symbol)
              "#{k}: #{value}"
            else
              "#{k.inspect} => #{value}"
            end
          end
        end
      end

      def up
        up_command + spacing(up_command)
      end

      def down
        down_command + spacing(down_command)
      end

      private

      def spacing(command)
        if command["\n"]
          "\n\n"
        else
          "\n"
        end
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
declare_schema-0.11.0 lib/declare_schema/schema_change/base.rb
declare_schema-0.10.1 lib/declare_schema/schema_change/base.rb