Class: Mongoid::SearchIndexable::Status Private

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid/search_indexable.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Represents the status of the indexes returned by a search_indexes call.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(indexes) ⇒ Status

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create a new Status object.

Parameters:

  • indexes (Array<Hash>)

    the raw index documents



20
21
22
# File 'lib/mongoid/search_indexable.rb', line 20

def initialize(indexes)
  @indexes = indexes
end

Instance Attribute Details

#indexesArray<Hash> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the raw index documents.

Returns:

  • (Array<Hash>)

    the raw index documents



15
16
17
# File 'lib/mongoid/search_indexable.rb', line 15

def indexes
  @indexes
end

Instance Method Details

#pendingArray<Hash>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the subset of indexes that have status == ‘PENDING’

Returns:

  • (Array<Hash>)

    index documents for “pending” indices



34
35
36
# File 'lib/mongoid/search_indexable.rb', line 34

def pending
  indexes.select { |i| i['status'] == 'PENDING' }
end

#queryableArray<Hash>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the subset of indexes that are marked ‘queryable’

Returns:

  • (Array<Hash>)

    index documents for ‘queryable’ indices



41
42
43
# File 'lib/mongoid/search_indexable.rb', line 41

def queryable
  indexes.select { |i| i['queryable'] }
end

#readyArray<Hash>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the subset of indexes that have status == ‘READY’

Returns:

  • (Array<Hash>)

    index documents for “ready” indices



27
28
29
# File 'lib/mongoid/search_indexable.rb', line 27

def ready
  indexes.select { |i| i['status'] == 'READY' }
end

#ready?true | false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns true if all the given indexes are ‘ready’ and ‘queryable’.

Returns:

  • (true | false)

    ready status of all indexes



48
49
50
# File 'lib/mongoid/search_indexable.rb', line 48

def ready?
  indexes.all? { |i| i['status'] == 'READY' && i['queryable'] }
end