Module: SimpleSolr::Update::ClassMethods

Defined in:
lib/simple_solr/update.rb

Instance Method Summary collapse

Instance Method Details

#field(name, value = nil) ⇒ Object

gets called by every field line inside the simple_solr block. It stores the given values in simple_solr_fields, which we later use to build the XML.



28
29
30
# File 'lib/simple_solr/update.rb', line 28

def field(name, value=nil)
  simple_solr_fields[name] = value
end

#simple_solr(&block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/simple_solr/update.rb', line 8

def simple_solr(&block)
  class_eval do
    # httparty
    include HTTParty
    
    # callbacks
    after_save :add_to_solr
    after_destroy :delete_from_solr
  end
  
  # Store the simple_solr fields for this class
  cattr_accessor :simple_solr_fields
  self.simple_solr_fields = { id: nil }
  block.call if block_given?
  
  include InstanceMethods
end