Class: ActsAsSolr::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_solr.rb,
lib/acts_as_solr/deprecation.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body, mode = :search) ⇒ Post

Returns a new instance of Post.


4
5
6
7
8
9
# File 'lib/acts_as_solr/deprecation.rb', line 4

def initialize(body, mode = :search)
  @body = body
  @mode = mode
  puts "The method ActsAsSolr::Post.new(body, mode).execute_post is depracated. " +
       "Use ActsAsSolr::Post.execute(body, mode) instead!"
end

Class Method Details

.execute(request, core = nil) ⇒ Object


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/acts_as_solr.rb', line 45

def self.execute(request, core = nil)
  begin
    if File.exists?(::Rails.root+'/config/solr.yml')
      config = YAML::load_file(::Rails.root+'/config/solr.yml')
      url = config[ENV['RAILS_ENV']]['url']
      # for backwards compatibility
      url ||= "http://#{config[ENV['RAILS_ENV']]['host']}:#{config[ENV['RAILS_ENV']]['port']}/#{config[ENV['RAILS_ENV']]['servlet_path']}"
    else
      url = 'http://localhost:8982/solr'
    end
    url += "/" + core if !core.nil?
    connection = Solr::Connection.new(url)
    return connection.send(request)
  rescue 
    raise "Couldn't connect to the Solr server at #{url}. #{$!}"
    false
  end
end

Instance Method Details

#execute_postObject


11
12
13
# File 'lib/acts_as_solr/deprecation.rb', line 11

def execute_post
  ActsAsSolr::Post.execute(@body, @mode)
end