Class: SolrPanel::Result

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

Overview

This is the result set

Instance Method Summary collapse

Constructor Details

#initializeResult

Returns a new instance of Result.



25
26
27
# File 'lib/solrpanel/result.rb', line 25

def initialize
  @attrs = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *value) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/solrpanel/result.rb', line 29

def method_missing(id, *value)
  str = id.id2name
  if (value.length == 1)
    if str =~ /^(.*)=$/
      index = $1
      @attrs[index.to_sym] = value[0]
    else
      raise "Missing method: #{str}"
    end
  elsif (value.length == 0)
    if @attrs.include?(id)
      return @attrs[id]
    else
      return nil
    end
  else
    raise "Illegal number of arguments given (#{value.length})"
  end
end