Sha256: c5f2a8529b91b64c9fb6ce912fc0f84c2d129d4bdb1c6602e9661f46aa26b100

Contents?: true

Size: 760 Bytes

Versions: 2

Compression:

Stored size: 760 Bytes

Contents

module ActiveRecord
  module ConnectionAdapters
    module SchemaStatements
      def index_name_with_simple(table_name, options)
        shorten_mode =
          case Thread.current[:simple_index_name_shorten_mode]
          when :enable
            true
          when :disable
            false
          else
            ActiveRecord::SimpleIndexName.config.auto_shorten
          end

        if shorten_mode
          if Hash === options && options[:column]
            Array.wrap(options[:column]) * "_and_"
          else
            index_name_without_simple(table_name, options)
          end
        else
          index_name_without_simple(table_name, options)
        end
      end

      alias_method_chain :index_name, :simple
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activerecord-simple_index_name-0.2.0 lib/active_record/simple_index_name/active_record_ext.rb
activerecord-simple_index_name-0.2.0.beta1 lib/active_record/simple_index_name/active_record_ext.rb