Sha256: 7c738c4b726a563db244a0d7745f560159e79edf9a24b8e88743bcf3ade4eb24

Contents?: true

Size: 661 Bytes

Versions: 3

Compression:

Stored size: 661 Bytes

Contents

module ActiveRecord
  module SimpleIndexName
    module ActiveRecordExt
      def index_name(table_name, options)
        if ActiveRecord::SimpleIndexName.current_shorten? && Hash === options && options[:column]
          Array.wrap(options[:column]) * "_and_"
        else
          super
        end
      end

      def rename_index(table_name, old_name, new_name)
        if ActiveRecord::SimpleIndexName.current_shorten? && old_name == new_name
          # nop
        else
          super
        end
      end
    end
  end
end

ActiveRecord::ConnectionAdapters::AbstractAdapter.class_eval do
  prepend ActiveRecord::SimpleIndexName::ActiveRecordExt
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-simple_index_name-1.0.1 lib/active_record/simple_index_name/active_record_ext.rb
activerecord-simple_index_name-1.0.0 lib/active_record/simple_index_name/active_record_ext.rb
activerecord-simple_index_name-0.4.0 lib/active_record/simple_index_name/active_record_ext.rb