Module: Elastic::Railties::TypeExtensions::ClassMethods

Defined in:
lib/elastic/railties/type_extensions.rb

Instance Method Summary collapse

Instance Method Details

#delete_later(_object) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/elastic/railties/type_extensions.rb', line 21

def delete_later(_object)
  wrapped = new(_object)

  Jobs::DeletingJob
    .set(queue: Elastic.config.active_job_queue)
    .perform_later(to_s, wrapped.as_elastic_document(only_meta: true).as_json)
end

#index_later(_object) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/elastic/railties/type_extensions.rb', line 13

def index_later(_object)
  wrapped = new(_object)

  Jobs::IndexingJob
    .set(queue: Elastic.config.active_job_queue)
    .perform_later(to_s, wrapped.as_elastic_document.as_json)
end

#references(*_includes) ⇒ Object



8
9
10
11
# File 'lib/elastic/railties/type_extensions.rb', line 8

def references(*_includes)
  # TODO: check target allows options
  pre_definition.middleware_options[:ar_collect_includes] = _includes
end