Class: ActsAsSolr::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_solr/post.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


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

def config
  return @config if @config
  @config = {}
  YAML::load_file("#{Rails.root}/config/solr.yml")[Rails.env].each{ |k,v| @config[k.to_sym] = v }
  @config
end

.credentialsObject


15
16
17
# File 'lib/acts_as_solr/post.rb', line 15

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

.execute(request, core = nil) ⇒ Object


23
24
25
26
# File 'lib/acts_as_solr/post.rb', line 23

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

.optionsObject


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

def options
  @options ||= credentials.merge config
end

.url(core) ⇒ Object


19
20
21
# File 'lib/acts_as_solr/post.rb', line 19

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