Class: CouchdbRebuildViewIndices::Indexer

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

Overview

Class for describing an indexer of CouchDB design documents.

Constant Summary collapse

@@default_options =
{
  host: '127.0.0.1',
  retries: 10,
  port: 5984,
  protocol: 'http',
  log_level: Logger::INFO
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Indexer

Returns a new instance of Indexer.



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

def initialize(options)
  @options = @@default_options.merge!(options)
  @logger = Logger.new(STDOUT)
  @logger.level = @options[:log_level]
  @logger.debug 'Running with options:'
  @logger.debug @options
end

Instance Attribute Details

#options=(value) ⇒ Object (writeonly)

Sets the attribute options

Parameters:

  • value

    the value to set the attribute options to.



11
12
13
# File 'lib/couchdb_rebuild_view_indices.rb', line 11

def options=(value)
  @options = value
end

Instance Method Details

#run!Object



29
30
31
32
33
34
35
# File 'lib/couchdb_rebuild_view_indices.rb', line 29

def run!
  docs = get_design_docs(design_docs_uri)
  docs.each do |doc|
    next unless doc['doc'].key?('views')
    iterate_on_views(doc['id'], doc['doc']['views'])
  end
end