class Solr4R::Result

Attributes

response[R]

Public Class Methods

new(response, hash) click to toggle source
# File lib/solr4r/result.rb, line 46
def initialize(response, hash)
  @response, @hash = response, hash.extend(Nuggets::Hash::DeepFetchMixin)

  self.class.types.each { |key, mod|
    extend(mod) if val = hash.key?(key)

    respond_to?(meth = "#{key}?", true) or
      define_singleton_method(meth) { val }
  }
end
types() click to toggle source
# File lib/solr4r/result.rb, line 39
def self.types
  @types ||= constants.each_with_object({}) { |const, hash|
    mod, key = const_get(const), const.to_s; next unless mod.is_a?(Module)
    hash[key.extend(Nuggets::String::CamelscoreMixin).underscore!] = mod
  }
end

Public Instance Methods

each(&block) click to toggle source
# File lib/solr4r/result.rb, line 71
def each(&block)
  block ? _each(&block) : enum_for(__method__)
end
empty?() click to toggle source
# File lib/solr4r/result.rb, line 75
def empty?
  to_i.zero?
end
to_hash() click to toggle source
# File lib/solr4r/result.rb, line 63
def to_hash
  @hash
end
to_i() click to toggle source
# File lib/solr4r/result.rb, line 67
def to_i
  0
end

Private Instance Methods

_each() click to toggle source
# File lib/solr4r/result.rb, line 81
def _each
  []
end