Sha256: d018906429b4ddc908ed3562dad9f8c7e8428cddf9e01e313ca6cf9d50102d91

Contents?: true

Size: 880 Bytes

Versions: 2

Compression:

Stored size: 880 Bytes

Contents

# encoding: UTF-8
module MongoMapper
  module Plugins
    module Indexes
      extend ActiveSupport::Concern

      module ClassMethods
        def ensure_index(spec, options = {})
          collection.ensure_index dealias_options(spec), options
        end

        def create_index(spec, options = {})
          collection.create_index dealias_options(spec), options
        end

        def drop_index(name)
          collection.drop_index name
        end

        def drop_indexes
          collection.drop_indexes
        end

        private

        def dealias_options(options)
          case options
          when Symbol, String
             abbr(options)
          when Hash
            dealias_keys(options)
          when Array
            options.map {|o| dealias_options(o) }
          else
            options
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongo_mapper-0.13.1 lib/mongo_mapper/plugins/indexes.rb
mongo_mapper-0.13.0 lib/mongo_mapper/plugins/indexes.rb