Class: MARCSpec::MockSolrDoc

Inherits:
Hash
  • Object
show all
Defined in:
lib/marcspec/specset.rb

Overview

Create a mock solr document based on a normal hash for mocking. All we really need is a compatible add method

Instance Method Summary collapse

Instance Method Details

#add(key, value) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/marcspec/specset.rb', line 12

def add key, value
  if self.has_key? key
    self[key] << value
  else
    self[key] = [value]
  end
  self[key].flatten!      
end

#additive_merge!(hashlike) ⇒ Object



21
22
23
24
25
# File 'lib/marcspec/specset.rb', line 21

def additive_merge! hashlike
  hashlike.each  do |k, v|
    self.add(k, v)
  end
end