Parent

Class/Module Index [+]

Quicksearch

ChefZero::Solr::SolrDoc

This does what expander does, flattening the json doc into keys and values so that solr can search them.

Public Class Methods

new(json, id) click to toggle source
# File lib/chef_zero/solr/solr_doc.rb, line 6
def initialize(json, id)
  @json = json
  @id = id
end

Public Instance Methods

[](key) click to toggle source
# File lib/chef_zero/solr/solr_doc.rb, line 11
def [](key)
  matching_values { |match_key| match_key == key }
end
matching_values(&block) click to toggle source
# File lib/chef_zero/solr/solr_doc.rb, line 15
def matching_values(&block)
  result = []
  key_values(nil, @json) do |key, value|
    if block.call(key)
      result << value.to_s
    end
  end
  # Handle manufactured value(s)
  if block.call('X_CHEF_id_CHEF_X')
    result << @id.to_s
  end

  result.uniq
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.