module Faststep
  class Collection
    def index_information
      info = {}
      db["system.indexes"].find({:ns => ns}).each do |index|
        info[index['name']] = index
      end
      info
    end

    def rename(new_name)
      connection["admin"].command(:renameCollection => ns, :to => "#{db.name}.#{new_name}")
      @name = new_name
      true
    end

    def drop_index(index_name)
      db.command(:deleteIndexes => self.name, :index => index_name)
      true
    end
  end
end

module Faststep
  class Collection
    def index_information
      info = {}
      db["system.indexes"].find({:ns => ns}).each do |index|
        info[index['name']] = index
      end
      info
    end

    def rename(new_name)
      command = BSON::OrderedHash.new
      command[:renameCollection] = ns
      command[:to] = "#{db.name}.#{new_name}"
      connection["admin"].command(command)
      @name = new_name
      true
    end

    def drop_index(index_name)
      db.command(:deleteIndexes => self.name, :index => index_name)
      true
    end
  end
end

Fix rename to use ordered hash to run on non-1.9 Rubies
Fix rename to use ordered hash to run on non-1.9 Rubies
