Class: Mongo::Admin Deprecated

Inherits:
Object show all
Defined in:
lib/mongo/admin.rb

Overview

Deprecated.

this class is deprecated. Methods defined here will henceforth be available in Mongo::DB.

Instance Method Summary collapse

Constructor Details

#initialize(db) ⇒ Admin

Returns a new instance of Admin.



23
24
25
26
# File 'lib/mongo/admin.rb', line 23

def initialize(db)
  warn "The Admin class has been DEPRECATED. All admin methods now exist in DB."
  @db = db
end

Instance Method Details

#profiling_infoObject

Deprecated.

please use DB#profiling_info instead.

Returns an array containing current profiling information.



74
75
76
77
# File 'lib/mongo/admin.rb', line 74

def profiling_info
  warn "Admin#profiling_info has been DEPRECATED. Please use DB#profiling_info instead."
  Cursor.new(Collection.new(@db, DB::SYSTEM_PROFILE_COLLECTION), :selector => {}).to_a
end

#profiling_levelSymbol

Deprecated.

please use DB#profiling_level instead.

Return the current database profiling level.

Returns:

  • (Symbol)

    :off, :slow_only, or :all



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/mongo/admin.rb', line 33

def profiling_level
  warn "Admin#profiling_level has been DEPRECATED. Please use DB#profiling_level instead."
  oh = OrderedHash.new
  oh[:profile] = -1
  doc = @db.command(oh)
  raise "Error with profile command: #{doc.inspect}" unless @db.ok?(doc) && doc['was'].kind_of?(Numeric)
  case doc['was'].to_i
  when 0
    :off
  when 1
    :slow_only
  when 2
    :all
  else
    raise "Error: illegal profiling level value #{doc['was']}"
  end
end

#profiling_level=(level) ⇒ Object

Deprecated.

please use DB#profiling_level= instead.

Set database profiling level to :off, :slow_only, or :all.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/mongo/admin.rb', line 54

def profiling_level=(level)
  warn "Admin#profiling_level= has been DEPRECATED. Please use DB#profiling_level= instead."
  oh = OrderedHash.new
  oh[:profile] = case level
                 when :off
                   0
                 when :slow_only
                   1
                 when :all
                   2
                 else
                   raise "Error: illegal profiling level value #{level}"
                 end
  doc = @db.command(oh)
  raise "Error with profile command: #{doc.inspect}" unless @db.ok?(doc)
end

#validate_collection(name) ⇒ Object

Deprecated.

please use DB#validate_collection instead.

Validate a named collection by raising an exception if there is a problem or returning an interesting hash (see especially the ‘result’ string value) if all is well.



84
85
86
87
88
89
90
91
92
# File 'lib/mongo/admin.rb', line 84

def validate_collection(name)
  warn "Admin#validate_collection has been DEPRECATED. Please use DB#validate_collection instead."
  doc = @db.command(:validate => name)
  raise "Error with validate command: #{doc.inspect}" unless @db.ok?(doc)
  result = doc['result']
  raise "Error with validation data: #{doc.inspect}" unless result.kind_of?(String)
  raise "Error: invalid collection #{name}: #{doc.inspect}" if result =~ /\b(exception|corrupt)\b/i
  doc
end