Class: Elasticsearch::Model::Extensions::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticsearch/model/extensions/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(active_record_class, parent_class: parent_class, delayed:, only_if: -> r { true }, records_to_update_documents: nil, field_to_update: nil, block: nil) ⇒ Configuration

Returns a new instance of Configuration.



7
8
9
10
11
12
13
14
15
16
# File 'lib/elasticsearch/model/extensions/configuration.rb', line 7

def initialize(active_record_class, parent_class: parent_class, delayed:, only_if: -> r { true }, records_to_update_documents: nil, field_to_update: nil, block: nil)
  @delayed = @delayed

  @active_record_class = active_record_class
  @parent_class = parent_class
  @if = binding.local_variable_get(:only_if)
  @records_to_update_documents = records_to_update_documents
  @field_to_update = field_to_update
  @block = block
end

Instance Attribute Details

#delayedObject (readonly)

Returns the value of attribute delayed.



5
6
7
# File 'lib/elasticsearch/model/extensions/configuration.rb', line 5

def delayed
  @delayed
end

Instance Method Details

#blockObject



38
39
40
# File 'lib/elasticsearch/model/extensions/configuration.rb', line 38

def block
  to_hash[:block]
end

#field_to_updateObject



22
23
24
# File 'lib/elasticsearch/model/extensions/configuration.rb', line 22

def field_to_update
  to_hash[:field_to_update]
end

#only_ifObject



26
27
28
# File 'lib/elasticsearch/model/extensions/configuration.rb', line 26

def only_if
  to_hash[:only_if]
end

#optionally_delayedObject



34
35
36
# File 'lib/elasticsearch/model/extensions/configuration.rb', line 34

def optionally_delayed
  -> t { delayed ? t.delay : t }
end

#records_to_update_documentsObject



30
31
32
# File 'lib/elasticsearch/model/extensions/configuration.rb', line 30

def records_to_update_documents
  to_hash[:records_to_update_documents]
end

#to_hashObject



18
19
20
# File 'lib/elasticsearch/model/extensions/configuration.rb', line 18

def to_hash
  @cached_hash ||= build_hash
end