Module: Elasticsearch::Persistence::Repository::DSL::ClassMethods

Defined in:
lib/elasticsearch/persistence/repository/dsl.rb

Overview

These methods are necessary to define at the class-level so that the methods available via Elasticsearch::Model::Indexing::ClassMethods have the references they depend on.

Since:

  • 6.0.0

Instance Method Summary collapse

Instance Method Details

#client(_client = nil) ⇒ Class

Get or set the class-level setting for the client used by the repository.

Examples:

MyRepository.client

Returns:

  • (Class)

    _client The repository’s client.

Since:

  • 6.0.0



82
83
84
# File 'lib/elasticsearch/persistence/repository/dsl.rb', line 82

def client(_client = nil)
  @client ||= (_client || Elasticsearch::Client.new)
end

#create_index!(*args) ⇒ Object

Since:

  • 6.0.0



86
87
88
# File 'lib/elasticsearch/persistence/repository/dsl.rb', line 86

def create_index!(*args)
  __raise_not_implemented_error(__method__)
end

#delete_index!(*args) ⇒ Object

Since:

  • 6.0.0



90
91
92
# File 'lib/elasticsearch/persistence/repository/dsl.rb', line 90

def delete_index!(*args)
  __raise_not_implemented_error(__method__)
end

#document_type(_type = nil) ⇒ String, Symbol

Get or set the class-level document type setting.

Examples:

MyRepository.document_type

Returns:

  • (String, Symbol)

    _type The repository’s document type.

Since:

  • 6.0.0



46
47
48
# File 'lib/elasticsearch/persistence/repository/dsl.rb', line 46

def document_type(_type = nil)
  @document_type ||= _type
end

#index_exists?(*args) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 6.0.0



98
99
100
# File 'lib/elasticsearch/persistence/repository/dsl.rb', line 98

def index_exists?(*args)
  __raise_not_implemented_error(__method__)
end

#index_name(_name = nil) ⇒ String, Symbol

Get or set the class-level index name setting.

Examples:

MyRepository.index_name

Returns:

  • (String, Symbol)

    _name The repository’s index name.

Since:

  • 6.0.0



58
59
60
# File 'lib/elasticsearch/persistence/repository/dsl.rb', line 58

def index_name(_name = nil)
  @index_name ||= (_name || DEFAULT_INDEX_NAME)
end

#klass(_class = nil) ⇒ Class

Get or set the class-level setting for the class used by the repository when deserializing.

Examples:

MyRepository.klass

Returns:

  • (Class)

    _class The repository’s klass for deserializing.

Since:

  • 6.0.0



70
71
72
# File 'lib/elasticsearch/persistence/repository/dsl.rb', line 70

def klass(_class = nil)
  instance_variables.include?(:@klass) ? @klass : @klass = _class
end

#refresh_index!(*args) ⇒ Object

Since:

  • 6.0.0



94
95
96
# File 'lib/elasticsearch/persistence/repository/dsl.rb', line 94

def refresh_index!(*args)
  __raise_not_implemented_error(__method__)
end