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

.configObject



26
27
28
# File 'lib/acts_as_solr.rb', line 26

def config
  @config ||= YAML::load_file("#{Rails.root}/config/solr.yml")[Rails.env]
end

.credentialsObject



30
31
32
# File 'lib/acts_as_solr.rb', line 30

def credentials
  @credentials ||= {:username => config['username'], :password => config['password']}
end

.execute(request, core = nil) ⇒ Object



38
39
40
41
# File 'lib/acts_as_solr.rb', line 38

def execute(request, core = nil)
  connection = Solr::Connection.new(url(core), credentials)
  connection.send request
end

.url(core) ⇒ Object



34
35
36
# File 'lib/acts_as_solr.rb', line 34

def url(core)
  core.nil? ? config['url'] : "#{config['url']}/#{core}"
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