Module: Elasticshell::Scopes

Defined in:
lib/elasticshell/scopes.rb,
lib/elasticshell/scopes/index.rb,
lib/elasticshell/scopes/nodes.rb,
lib/elasticshell/scopes/global.rb,
lib/elasticshell/scopes/cluster.rb,
lib/elasticshell/scopes/mapping.rb

Defined Under Namespace

Classes: Cluster, Global, Index, Mapping, Nodes

Class Method Summary collapse

Class Method Details

.cluster(options = {}) ⇒ Object



17
18
19
# File 'lib/elasticshell/scopes.rb', line 17

def self.cluster options={}
  Cluster.new(options)
end

.from_path(path, options = {}) ⇒ Object



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

def self.from_path path, options={}
  segments = path.to_s.strip.gsub(%r!^/!,'').gsub(%r!/$!,'').split('/')
  case
  when segments.length == 0
    global(options)
  when segments.length == 1 && segments.first == '_cluster'
    cluster(options)
  when segments.length == 1 && segments.first == '_nodes'
    nodes(options)
  when segments.length == 1
    index(segments.first, options)
  when segments.length == 2
    mapping(segments[0], segments[1], options)
  else
    raise ArgumentError.new("'#{path}' does not define a valid path for a scope.")
  end
end

.global(options = {}) ⇒ Object



13
14
15
# File 'lib/elasticshell/scopes.rb', line 13

def self.global options={}
  Global.new(options)
end

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



25
26
27
# File 'lib/elasticshell/scopes.rb', line 25

def self.index name, options={}
  Index.new(name, options)
end

.mapping(index_name, mapping_name, options = {}) ⇒ Object



29
30
31
# File 'lib/elasticshell/scopes.rb', line 29

def self.mapping index_name, mapping_name, options={}
  Mapping.new(index(index_name, options), mapping_name, options)
end

.nodes(options = {}) ⇒ Object



21
22
23
# File 'lib/elasticshell/scopes.rb', line 21

def self.nodes options={}
  Nodes.new(options)
end