Module: Elasticord::Base::ClassMethods

Extended by:
Forwardable
Included in:
Elasticord::Base
Defined in:
lib/elasticord/base.rb

Instance Method Summary collapse

Instance Method Details

#client(sub_index = nil, sub_type = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/elasticord/base.rb', line 10

def client(sub_index = nil, sub_type = nil)
  full_type = [type, sub_type].compact.join('_')


  full_index = [index, sub_index].compact.join('_')

  Client::Base.new \
    Elasticord.elastic_search_client, self, full_index, full_type
end

#indexObject



29
30
31
32
33
34
35
# File 'lib/elasticord/base.rb', line 29

def index
  return @index if defined?(@index)

  @index = (superclass.index || '').dup if superclass.respond_to? :index

  @index = @index.presence || Elasticord::Config.get(:index_namespace)
end

#index=(new_index) ⇒ Object



37
38
39
# File 'lib/elasticord/base.rb', line 37

def index=(new_index)
  @index = new_index
end

#typeObject



41
42
43
44
45
46
47
# File 'lib/elasticord/base.rb', line 41

def type
  return @type if defined?(@type)

  return (@type = '_all') if name.nil? || name == 'Elasticord::Base'

  @type = name.split('::').last.underscore
end