Module: PostJson::DynamicIndexMethods::ClassMethods

Defined in:
lib/post_json/concerns/dynamic_index_methods.rb

Instance Method Summary collapse

Instance Method Details

#create_dynamic_index(selector) ⇒ Object


14
15
16
# File 'lib/post_json/concerns/dynamic_index_methods.rb', line 14

def create_dynamic_index(selector)
  create_dynamic_indexes(selector)
end

#create_dynamic_indexes(*selectors) ⇒ Object


18
19
20
# File 'lib/post_json/concerns/dynamic_index_methods.rb', line 18

def create_dynamic_indexes(*selectors)
  DynamicIndex.ensure_index(persisted_settings.id, *selectors).count
end

#destroy_dynamic_index(selector) ⇒ Object


22
23
24
25
26
27
28
# File 'lib/post_json/concerns/dynamic_index_methods.rb', line 22

def destroy_dynamic_index(selector)
  if settings.new_record?
    false
  else
    DynamicIndex.destroy_index(settings.id, selector)
  end
end

#dynamic_indexesObject


6
7
8
9
10
11
12
# File 'lib/post_json/concerns/dynamic_index_methods.rb', line 6

def dynamic_indexes
  if settings.new_record?
    []
  else
    DynamicIndex.indexed_selectors(settings.id)
  end
end