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-1.4.0 lib/declare_schema/schema_change/base.rb
declare_schema-1.4.0.colin.11 lib/declare_schema/schema_change/base.rb
declare_schema-1.3.6 lib/declare_schema/schema_change/base.rb
declare_schema-1.3.6.colin.1 lib/declare_schema/schema_change/base.rb
declare_schema-1.3.5 lib/declare_schema/schema_change/base.rb
declare_schema-1.3.5.colin.1 lib/declare_schema/schema_change/base.rb
declare_schema-1.4.0.colin.9 lib/declare_schema/schema_change/base.rb
declare_schema-1.3.4 lib/declare_schema/schema_change/base.rb
declare_schema-1.3.4.colin.1 lib/declare_schema/schema_change/base.rb
declare_schema-1.4.0.colin.8 lib/declare_schema/schema_change/base.rb
declare_schema-1.3.3 lib/declare_schema/schema_change/base.rb
declare_schema-1.3.3.colin.1 lib/declare_schema/schema_change/base.rb
declare_schema-1.4.0.colin.7 lib/declare_schema/schema_change/base.rb
declare_schema-1.4.0.colin.6 lib/declare_schema/schema_change/base.rb
declare_schema-1.4.0.colin.5 lib/declare_schema/schema_change/base.rb
declare_schema-1.4.0.colin.4 lib/declare_schema/schema_change/base.rb
declare_schema-1.4.0.colin.3 lib/declare_schema/schema_change/base.rb
declare_schema-1.4.0.colin.2 lib/declare_schema/schema_change/base.rb
declare_schema-1.4.0.colin.1 lib/declare_schema/schema_change/base.rb
declare_schema-1.3.2 lib/declare_schema/schema_change/base.rb