Class ActsAsSolr::Post
In: lib/acts_as_solr.rb
lib/deprecation.rb
Parent: Object

Methods

execute   execute_post   new  

Public Class methods

[Source]

# File lib/acts_as_solr.rb, line 36
    def self.execute(body, mode = :search)
      begin
        if File.exists?(RAILS_ROOT+'/config/solr.yml')
          config = YAML::load_file(RAILS_ROOT+'/config/solr.yml')
          server = config[RAILS_ENV]['host']
          port = config[RAILS_ENV]['port']
          servlet_path = config[RAILS_ENV]['servlet_path']
        else
          server = 'localhost'
          port   = 8982
          servlet_path = 'solr'
        end
        url = URI.parse("http://#{server}:#{port}")
        post = Net::HTTP::Post.new(mode == :search ? "/#{servlet_path}/select" : "/#{servlet_path}/update")
        post.body = body
        post.content_type = 'application/x-www-form-urlencoded; charset=utf-8'
        response = Net::HTTP.start(url.host, url.port) do |http|
          http.request(post)
        end
        return response.body    
      rescue 
        raise "Couldn't connect to the Solr server on #{server}:#{port} located at /#{servlet_path}. #{$!}"
        false
      end
    end

[Source]

# 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 " +
           "and will be obsolete by version 1.0. Use ActsAsSolr::Post.execute(body, mode) instead!"
    end

Public Instance methods

[Source]

# File lib/deprecation.rb, line 11
    def execute_post
      ActsAsSolr::Post.execute(@body, @mode)
    end

[Validate]