Class: Elasticshell::Scopes::Global

Inherits:
Elasticshell::Scope show all
Defined in:
lib/elasticshell/scopes/global.rb

Constant Summary

Constants included from HasVerb

HasVerb::VERBS

Instance Attribute Summary collapse

Attributes inherited from Elasticshell::Scope

#client, #last_refresh_at, #path, #scopes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Elasticshell::Scope

#completing_scope_path_and_prefix, #completion_proc, #refresh, #refresh!, #refreshed?, #request_names, #requests, #requests_matching, #scopes_matching, #to_s

Methods included from HasVerb

#verb, #verb=

Constructor Details

#initialize(options = {}) ⇒ Global

Returns a new instance of Global.



9
10
11
12
# File 'lib/elasticshell/scopes/global.rb', line 9

def initialize options={}
  @indices = []
  super("/", options)
end

Instance Attribute Details

#indicesObject (readonly)

Returns the value of attribute indices.



7
8
9
# File 'lib/elasticshell/scopes/global.rb', line 7

def indices
  @indices
end

Class Method Details

.requestsObject



14
15
16
17
18
19
20
21
# File 'lib/elasticshell/scopes/global.rb', line 14

def self.requests
  @requests ||= {
    "GET" => {
      '_status'  => "Retreive the status of all indices in the cluster.",
      '_count'   => "Count all records."
    }
  }
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/elasticshell/scopes/global.rb', line 46

def exists?
  true
end

#fetch_scopesObject



37
38
39
40
# File 'lib/elasticshell/scopes/global.rb', line 37

def fetch_scopes
  @indices = status["indices"].keys
  self.scopes += @indices
end

#index(name, options = {}) ⇒ Object



42
43
44
# File 'lib/elasticshell/scopes/global.rb', line 42

def index name, options={}
  Scopes.index(name, options, :client => client)
end

#initial_scopesObject



23
24
25
# File 'lib/elasticshell/scopes/global.rb', line 23

def initial_scopes
  ['_cluster', '_nodes']
end

#reset!Object



31
32
33
34
35
# File 'lib/elasticshell/scopes/global.rb', line 31

def reset!
  @indices = []
  @status  = nil
  super()
end

#statusObject



27
28
29
# File 'lib/elasticshell/scopes/global.rb', line 27

def status
  @status ||= client.safely(:get, {:index => '_status'}, :return => {"indices" => {}}, :log => false)
end