Class/Module Index [+]

Quicksearch

Chef::IndexQueue::Indexable

Attributes

index_id[RW]

Public Class Methods

included(including_class) click to toggle source
# File lib/chef/index_queue/indexable.rb, line 40
def self.included(including_class)
  including_class.send(:extend, ClassMethods)
end

Public Instance Methods

add_to_index(metadata={}) click to toggle source
# File lib/chef/index_queue/indexable.rb, line 68
def add_to_index(metadata={})
 Chef::Log.debug("Pushing item to index queue for addition: #{self.with_indexer_metadata(metadata)}")
 object_with_metadata = with_indexer_metadata(metadata)
 obj_id = object_with_metadata["id"]
 obj = {:action => :add, :payload => self.with_indexer_metadata(metadata)}

 publish_object(obj_id, obj)
end
delete_from_index(metadata={}) click to toggle source
# File lib/chef/index_queue/indexable.rb, line 77
def delete_from_index(metadata={})
  Chef::Log.debug("Pushing item to index queue for deletion: #{self.with_indexer_metadata(metadata)}")
  object_with_metadata = with_indexer_metadata(metadata)
  obj_id = object_with_metadata["id"]
  obj = {:action => :delete, :payload => self.with_indexer_metadata(metadata)}

  publish_object(obj_id, obj)
end
index_object_type() click to toggle source
# File lib/chef/index_queue/indexable.rb, line 46
def index_object_type
  self.class.index_object_type || Mixin::ConvertToClassName.snake_case_basename(self.class.name)
end
with_indexer_metadata(indexer_metadata={}) click to toggle source
# File lib/chef/index_queue/indexable.rb, line 50
def with_indexer_metadata(indexer_metadata={})
  # changing input param symbol keys to strings, as the keys in hash that goes to solr are expected to be strings [cb]
  # Ruby 1.9 hates you, cb [dan]
  with_metadata = {}
  indexer_metadata.each_key do |key|
    with_metadata[key.to_s] = indexer_metadata[key]
  end

  with_metadata["type"]     ||= self.index_object_type
  with_metadata["id"]       ||= self.index_id
  with_metadata["database"] ||= Chef::Config[:couchdb_database]
  with_metadata["item"]     ||= self.to_hash
  with_metadata["enqueued_at"] ||= Time.now.utc.to_i

  raise ArgumentError, "Type, Id, or Database missing in index operation: #{with_metadata.inspect}" if (with_metadata["id"].nil? or with_metadata["type"].nil?)
  with_metadata        
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.