Class: Elastics::Tasks

Inherits:
Object
  • Object
show all
Defined in:
lib/elastics/tasks.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(overrides = {}) ⇒ Tasks

Returns a new instance of Tasks.



6
7
8
9
10
# File 'lib/elastics/tasks.rb', line 6

def initialize(overrides={})
  options = Elastics::Utils.env2options *default_options.keys
  options[:index] = options[:index].split(',') if options[:index]
  @options = default_options.merge(options).merge(overrides)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/elastics/tasks.rb', line 4

def options
  @options
end

Instance Method Details

#create_indicesObject



17
18
19
20
# File 'lib/elastics/tasks.rb', line 17

def create_indices
  Conf.indices.delete_indices(options[:index]) if options[:force]
  Conf.indices.create_indices(options[:index])
end

#default_optionsObject



12
13
14
15
# File 'lib/elastics/tasks.rb', line 12

def default_options
  @default_options ||= { :force => false,
                         :index => Conf.indices.keys }
end

#delete_indicesObject



22
23
24
# File 'lib/elastics/tasks.rb', line 22

def delete_indices
  Conf.indices.delete_indices(options[:index])
end