deprecation.rb
1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
module ActsAsSolr #:nodoc:
class Post
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
def execute_post
ActsAsSolr::Post.execute(@body, @mode)
end
end
module ClassMethods
def find_with_facet(query, options={})
Deprecation.plog "The method find_with_facet is deprecated. Use find_by_solr instead, passing the " +
"arguments the same way you used to do with find_with_facet."
find_by_solr(query, options)
end
end
class Deprecation
# Validates the options passed during query
def self.validate_query options={}
if options[:field_types]
plog "The option :field_types for searching is deprecated. " +
"The field types are automatically traced back when you specify a field type in your model."
end
if options[:sort_by]
plog "The option :sort_by is deprecated, use :order instead!"
options[:order] ||= options[:sort_by]
end
if options[:start]
plog "The option :start is deprecated, use :offset instead!"
options[:offset] ||= options[:start]
end
if options[:rows]
plog "The option :rows is deprecated, use :limit instead!"
options[:limit] ||= options[:rows]
end
end
# Validates the options passed during indexing
def self.validate_index options={}
if options[:background]
plog "The :background option is being deprecated. There are better and more efficient " +
"ways to handle delayed saving of your records."
end
end
# This will print the text to stdout and log the text
# if rails logger is available
def self.plog text
puts text
RAILS_DEFAULT_LOGGER.warn text if defined? RAILS_DEFAULT_LOGGER
end
end
end