Class: ActsAsSolr::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/deprecation.rb,
lib/acts_as_solr.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/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) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/acts_as_solr.rb', line 39

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

Instance Method Details

#execute_postObject



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

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