searchlogic 1.6.6 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/CHANGELOG.rdoc +17 -0
- data/{MIT-LICENSE → LICENSE} +2 -2
- data/README.rdoc +128 -379
- data/Rakefile +56 -20
- data/VERSION.yml +4 -0
- data/init.rb +1 -1
- data/lib/searchlogic.rb +18 -98
- data/lib/searchlogic/core_ext/object.rb +33 -13
- data/lib/searchlogic/core_ext/proc.rb +11 -0
- data/lib/searchlogic/named_scopes/alias_scope.rb +63 -0
- data/lib/searchlogic/named_scopes/associations.rb +126 -0
- data/lib/searchlogic/named_scopes/conditions.rb +215 -0
- data/lib/searchlogic/named_scopes/ordering.rb +53 -0
- data/lib/searchlogic/rails_helpers.rb +69 -0
- data/lib/searchlogic/search.rb +146 -0
- data/rails/init.rb +1 -0
- data/searchlogic.gemspec +69 -0
- data/spec/core_ext/object_spec.rb +7 -0
- data/spec/core_ext/proc_spec.rb +9 -0
- data/spec/named_scopes/alias_scope_spec.rb +15 -0
- data/spec/named_scopes/associations_spec.rb +120 -0
- data/spec/named_scopes/conditions_spec.rb +253 -0
- data/spec/named_scopes/ordering_spec.rb +23 -0
- data/spec/search_spec.rb +283 -0
- data/spec/spec_helper.rb +78 -0
- metadata +40 -231
- data/Manifest.txt +0 -158
- data/TODO.rdoc +0 -4
- data/lib/searchlogic/active_record/associations.rb +0 -52
- data/lib/searchlogic/active_record/base.rb +0 -224
- data/lib/searchlogic/active_record/connection_adapters/mysql_adapter.rb +0 -176
- data/lib/searchlogic/active_record/connection_adapters/postgresql_adapter.rb +0 -172
- data/lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb +0 -80
- data/lib/searchlogic/condition/base.rb +0 -165
- data/lib/searchlogic/condition/begins_with.rb +0 -17
- data/lib/searchlogic/condition/blank.rb +0 -24
- data/lib/searchlogic/condition/child_of.rb +0 -11
- data/lib/searchlogic/condition/descendant_of.rb +0 -11
- data/lib/searchlogic/condition/ends_with.rb +0 -17
- data/lib/searchlogic/condition/equals.rb +0 -33
- data/lib/searchlogic/condition/greater_than.rb +0 -15
- data/lib/searchlogic/condition/greater_than_or_equal_to.rb +0 -15
- data/lib/searchlogic/condition/inclusive_descendant_of.rb +0 -10
- data/lib/searchlogic/condition/keywords.rb +0 -52
- data/lib/searchlogic/condition/less_than.rb +0 -15
- data/lib/searchlogic/condition/less_than_or_equal_to.rb +0 -15
- data/lib/searchlogic/condition/like.rb +0 -15
- data/lib/searchlogic/condition/nested_set.rb +0 -17
- data/lib/searchlogic/condition/nil.rb +0 -21
- data/lib/searchlogic/condition/not_begin_with.rb +0 -20
- data/lib/searchlogic/condition/not_blank.rb +0 -19
- data/lib/searchlogic/condition/not_end_with.rb +0 -20
- data/lib/searchlogic/condition/not_equal.rb +0 -27
- data/lib/searchlogic/condition/not_have_keywords.rb +0 -20
- data/lib/searchlogic/condition/not_like.rb +0 -20
- data/lib/searchlogic/condition/not_nil.rb +0 -19
- data/lib/searchlogic/condition/sibling_of.rb +0 -14
- data/lib/searchlogic/conditions/any_or_all.rb +0 -42
- data/lib/searchlogic/conditions/base.rb +0 -244
- data/lib/searchlogic/conditions/groups.rb +0 -74
- data/lib/searchlogic/conditions/magic_methods.rb +0 -286
- data/lib/searchlogic/conditions/multiparameter_attributes.rb +0 -105
- data/lib/searchlogic/conditions/protection.rb +0 -36
- data/lib/searchlogic/config.rb +0 -31
- data/lib/searchlogic/config/helpers.rb +0 -338
- data/lib/searchlogic/config/search.rb +0 -53
- data/lib/searchlogic/core_ext/hash.rb +0 -75
- data/lib/searchlogic/helpers/control_types/link.rb +0 -310
- data/lib/searchlogic/helpers/control_types/links.rb +0 -242
- data/lib/searchlogic/helpers/control_types/remote_link.rb +0 -87
- data/lib/searchlogic/helpers/control_types/remote_links.rb +0 -72
- data/lib/searchlogic/helpers/control_types/remote_select.rb +0 -36
- data/lib/searchlogic/helpers/control_types/select.rb +0 -82
- data/lib/searchlogic/helpers/form.rb +0 -208
- data/lib/searchlogic/helpers/utilities.rb +0 -197
- data/lib/searchlogic/modifiers/absolute.rb +0 -15
- data/lib/searchlogic/modifiers/acos.rb +0 -11
- data/lib/searchlogic/modifiers/asin.rb +0 -11
- data/lib/searchlogic/modifiers/atan.rb +0 -11
- data/lib/searchlogic/modifiers/avg.rb +0 -15
- data/lib/searchlogic/modifiers/base.rb +0 -27
- data/lib/searchlogic/modifiers/ceil.rb +0 -15
- data/lib/searchlogic/modifiers/char_length.rb +0 -15
- data/lib/searchlogic/modifiers/cos.rb +0 -15
- data/lib/searchlogic/modifiers/cot.rb +0 -15
- data/lib/searchlogic/modifiers/count.rb +0 -11
- data/lib/searchlogic/modifiers/day_of_month.rb +0 -15
- data/lib/searchlogic/modifiers/day_of_week.rb +0 -15
- data/lib/searchlogic/modifiers/day_of_year.rb +0 -15
- data/lib/searchlogic/modifiers/degrees.rb +0 -11
- data/lib/searchlogic/modifiers/exp.rb +0 -15
- data/lib/searchlogic/modifiers/floor.rb +0 -15
- data/lib/searchlogic/modifiers/hex.rb +0 -11
- data/lib/searchlogic/modifiers/hour.rb +0 -11
- data/lib/searchlogic/modifiers/log.rb +0 -15
- data/lib/searchlogic/modifiers/log10.rb +0 -11
- data/lib/searchlogic/modifiers/log2.rb +0 -11
- data/lib/searchlogic/modifiers/lower.rb +0 -15
- data/lib/searchlogic/modifiers/ltrim.rb +0 -15
- data/lib/searchlogic/modifiers/md5.rb +0 -11
- data/lib/searchlogic/modifiers/microseconds.rb +0 -11
- data/lib/searchlogic/modifiers/milliseconds.rb +0 -11
- data/lib/searchlogic/modifiers/minute.rb +0 -15
- data/lib/searchlogic/modifiers/month.rb +0 -15
- data/lib/searchlogic/modifiers/octal.rb +0 -15
- data/lib/searchlogic/modifiers/radians.rb +0 -11
- data/lib/searchlogic/modifiers/round.rb +0 -11
- data/lib/searchlogic/modifiers/rtrim.rb +0 -15
- data/lib/searchlogic/modifiers/second.rb +0 -15
- data/lib/searchlogic/modifiers/sign.rb +0 -11
- data/lib/searchlogic/modifiers/sin.rb +0 -11
- data/lib/searchlogic/modifiers/square_root.rb +0 -15
- data/lib/searchlogic/modifiers/sum.rb +0 -11
- data/lib/searchlogic/modifiers/tan.rb +0 -15
- data/lib/searchlogic/modifiers/trim.rb +0 -15
- data/lib/searchlogic/modifiers/upper.rb +0 -15
- data/lib/searchlogic/modifiers/week.rb +0 -11
- data/lib/searchlogic/modifiers/year.rb +0 -11
- data/lib/searchlogic/search/base.rb +0 -148
- data/lib/searchlogic/search/conditions.rb +0 -53
- data/lib/searchlogic/search/ordering.rb +0 -244
- data/lib/searchlogic/search/pagination.rb +0 -121
- data/lib/searchlogic/search/protection.rb +0 -89
- data/lib/searchlogic/search/searching.rb +0 -32
- data/lib/searchlogic/shared/utilities.rb +0 -57
- data/lib/searchlogic/shared/virtual_classes.rb +0 -39
- data/lib/searchlogic/version.rb +0 -79
- data/test/active_record_tests/associations_test.rb +0 -94
- data/test/active_record_tests/base_test.rb +0 -115
- data/test/condition_tests/base_test.rb +0 -62
- data/test/condition_tests/begins_with_test.rb +0 -11
- data/test/condition_tests/blank_test.rb +0 -31
- data/test/condition_tests/child_of_test.rb +0 -17
- data/test/condition_tests/descendant_of_test.rb +0 -12
- data/test/condition_tests/ends_with_test.rb +0 -11
- data/test/condition_tests/equals_test.rb +0 -28
- data/test/condition_tests/greater_than_or_equal_to_test.rb +0 -11
- data/test/condition_tests/greater_than_test.rb +0 -11
- data/test/condition_tests/inclusive_descendant_of_test.rb +0 -12
- data/test/condition_tests/keywords_test.rb +0 -23
- data/test/condition_tests/less_than_or_equal_to_test.rb +0 -11
- data/test/condition_tests/less_than_test.rb +0 -11
- data/test/condition_tests/like_test.rb +0 -11
- data/test/condition_tests/nil_test.rb +0 -31
- data/test/condition_tests/not_begin_with_test.rb +0 -8
- data/test/condition_tests/not_blank_test.rb +0 -8
- data/test/condition_tests/not_end_with_test.rb +0 -8
- data/test/condition_tests/not_equal_test.rb +0 -19
- data/test/condition_tests/not_have_keywords_test.rb +0 -8
- data/test/condition_tests/not_like_test.rb +0 -8
- data/test/condition_tests/not_nil_test.rb +0 -13
- data/test/condition_tests/sibling_of_test.rb +0 -15
- data/test/conditions_tests/any_or_all_test.rb +0 -23
- data/test/conditions_tests/base_test.rb +0 -185
- data/test/conditions_tests/groups_test.rb +0 -68
- data/test/conditions_tests/magic_methods_test.rb +0 -36
- data/test/conditions_tests/multiparameter_attributes_test.rb +0 -15
- data/test/conditions_tests/protection_test.rb +0 -18
- data/test/config_test.rb +0 -23
- data/test/fixtures/accounts.yml +0 -12
- data/test/fixtures/animals.yml +0 -7
- data/test/fixtures/orders.yml +0 -12
- data/test/fixtures/user_groups.yml +0 -5
- data/test/fixtures/users.yml +0 -45
- data/test/libs/awesome_nested_set.rb +0 -545
- data/test/libs/awesome_nested_set/.autotest +0 -13
- data/test/libs/awesome_nested_set/compatability.rb +0 -29
- data/test/libs/awesome_nested_set/helper.rb +0 -40
- data/test/libs/awesome_nested_set/named_scope.rb +0 -140
- data/test/libs/rexml_fix.rb +0 -14
- data/test/modifier_tests/day_of_month_test.rb +0 -16
- data/test/search_tests/base_test.rb +0 -241
- data/test/search_tests/conditions_test.rb +0 -21
- data/test/search_tests/ordering_test.rb +0 -167
- data/test/search_tests/pagination_test.rb +0 -74
- data/test/search_tests/protection_test.rb +0 -26
- data/test/test_helper.rb +0 -122
@@ -1,197 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Helpers #:nodoc:
|
3
|
-
module Utilities
|
4
|
-
# Builds a hash of params for creating a url and preserves any existing params. You can pass this into url_for and build your url. Although most rails helpers accept a hash.
|
5
|
-
#
|
6
|
-
# Let's take the page_link helper. Here is the code behind that helper:
|
7
|
-
#
|
8
|
-
# link_to("Page 2", searchlogic_params(:search_params => {:page => 2}))
|
9
|
-
#
|
10
|
-
# That's pretty much it. So if you wanted to roll your own link to execute a search, go for it. It's pretty simple. Pass conditions instead of the page, set how the search will be ordered, etc.
|
11
|
-
#
|
12
|
-
# <b>Be careful</b> when taking this approach though. Searchlogic helps you out when you use form_for. For example, when you use the per_page_select helper, it adds in a hidden form field with the value of the page. So when
|
13
|
-
# your search form is submitted it searches the document for that element, finds the current value, which is the current per_page value, and includes that in the search. So when a user searches the per_page
|
14
|
-
# value stays consistent. If you use the searchlogic_params you are on your own. I am always curious how people are using searchlogic. So if you are building your own helpers contact me and maybe I can help you
|
15
|
-
# and add in a helper for you, making it an *official* feature.
|
16
|
-
#
|
17
|
-
# === Options
|
18
|
-
# * <tt>:params_scope</tt> -- default: :search, this is the scope in which your search params will be preserved (params[:search]). If you don't want a scope and want your options to be at base leve in params such as params[:page], params[:per_page], etc, then set this to nil.
|
19
|
-
# * <tt>:search_obj</tt> -- default: @#{params_scope}, this is your search object, everything revolves around this. It will try to infer the name from your params_scope. If your params_scope is :search it will try to get @search, etc. If it can not be inferred by this, you need to pass the object itself.
|
20
|
-
# * <tt>:params</tt> -- default: nil, Additional params to add to the url, must be a hash
|
21
|
-
# * <tt>:exclude_params</tt> -- default: nil, params you want to exclude. This is nifty because it does a "deep delete". So you can pass {:param1 => {:param2 => :param3}} and it will make sure param3 does not get include. param1 and param2 will not be touched. This also accepts an array or just a symbol or string.
|
22
|
-
# * <tt>:search_params</tt> -- default: nil, Additional search params to add to the url, must be a hash. Adds the options into the :params_scope.
|
23
|
-
# * <tt>:exclude_search_params</tt> -- default: nil, Same as :exclude_params but for the :search_params.
|
24
|
-
def searchlogic_params(options = {})
|
25
|
-
add_searchlogic_defaults!(options)
|
26
|
-
options[:search_params] ||= {}
|
27
|
-
options[:literal_search_params] ||= {}
|
28
|
-
|
29
|
-
options[:params] ||= {}
|
30
|
-
params_copy = params.deep_dup.with_indifferent_access
|
31
|
-
search_params = options[:params_scope].blank? ? params_copy : params_copy.delete(options[:params_scope])
|
32
|
-
search_params ||= {}
|
33
|
-
search_params = search_params.with_indifferent_access
|
34
|
-
search_params.delete(:commit)
|
35
|
-
search_params.delete(:page)
|
36
|
-
search_params.deep_delete_duplicate_keys(options[:literal_search_params])
|
37
|
-
search_params.deep_delete(options[:exclude_search_params])
|
38
|
-
|
39
|
-
if options[:search_params]
|
40
|
-
|
41
|
-
#raise params_copy.inspect if options[:search_params][:order_by] == :id
|
42
|
-
search_params.deep_merge!(options[:search_params])
|
43
|
-
|
44
|
-
if options[:search_params][:order_by] && !options[:search_params][:order_as]
|
45
|
-
search_params[:order_as] = (searchlogic_ordering_by?(options[:search_params][:order_by], options) && options[:search_obj].asc?) ? "DESC" : "ASC"
|
46
|
-
end
|
47
|
-
|
48
|
-
[:order_by, :priority_order_by].each { |base64_field| search_params[base64_field] = searchlogic_base64_value(search_params[base64_field]) if search_params.has_key?(base64_field) }
|
49
|
-
end
|
50
|
-
|
51
|
-
new_params = params_copy
|
52
|
-
new_params.deep_merge!(options[:params])
|
53
|
-
new_params.deep_delete(options[:exclude_params])
|
54
|
-
|
55
|
-
if options[:params_scope].blank? || search_params.blank?
|
56
|
-
new_params
|
57
|
-
else
|
58
|
-
new_params.merge(options[:params_scope] => search_params)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# Similar to searchlogic_hash, but instead returns a string url. The reason this exists is to assist in creating urls in javascript. It's the muscle behind all of the select helpers that searchlogic provides.
|
63
|
-
# Take the instance where you want to do:
|
64
|
-
#
|
65
|
-
# :onchange => "window.location = '#{url_for(searchlogic_params)}&my_param=' + this.value;"
|
66
|
-
#
|
67
|
-
# Well the above obviously won't work. Do you need to apped the url with a ? or a &? What about that tricky :params_scope? That's where this is handy, beacuse it does all of the params string building for you. Check it out:
|
68
|
-
#
|
69
|
-
# :onchange => "window.location = '" + searchlogic_url(:literal_search_params => {:per_page => "' + escape(this.value) + '"}) + "';"
|
70
|
-
#
|
71
|
-
# or what about something a little more tricky?
|
72
|
-
#
|
73
|
-
# :onchange => "window.location = '" + searchlogic_url(:literal_search_params => {:conditions => {:name_contains => "' + escape(this.value) + '"}}) + "';"
|
74
|
-
#
|
75
|
-
# I have personally used this for an event calendar. Above the calendar there was a drop down for each month. Here is the code:
|
76
|
-
#
|
77
|
-
# :onchange => "window.location = '" + searchlogic_url(:literal_search_params => {:conditions => {:occurs_at_after => "' + escape(this.value) + '"}}) + "';"
|
78
|
-
#
|
79
|
-
# Now when the user changes the month in the drop down it just runs a new search that sets my conditions to occurs_at_after = selected month. Then in my controller I set occurs_at_before = occurs_at_after.at_end_of_month.
|
80
|
-
#
|
81
|
-
# === Options
|
82
|
-
# * <tt>:params_scope</tt> -- default: :search, this is the scope in which your search params will be preserved (params[:search]). If you don't want a scope and want your options to be at base leve in params such as params[:page], params[:per_page], etc, then set this to nil.
|
83
|
-
# * <tt>:search_obj</tt> -- default: @#{params_scope}, this is your search object, everything revolves around this. It will try to infer the name from your params_scope. If your params_scope is :search it will try to get @search, etc. If it can not be inferred by this, you need to pass the object itself.
|
84
|
-
# * <tt>:params</tt> -- default: nil, Additional params to add to the url, must be a hash
|
85
|
-
# * <tt>:exclude_params</tt> -- default: nil, params you want to exclude. This is nifty because it does a "deep delete". So you can pass {:param1 => {:param2 => :param3}} and it will make sure param3 does not get include. param1 and param2 will not be touched. This also accepts an array or just a symbol or string.
|
86
|
-
# * <tt>:search_params</tt> -- default: nil, Additional search params to add to the url, must be a hash. Adds the options into the :params_scope.
|
87
|
-
# * <tt>:literal_search_params</tt> -- default: nil, Additional search params to add to the url, but are not escaped. So you can add javascript into the URL: :literal_search_params => {:per_page => "' + escape(this.value) + '"}
|
88
|
-
# * <tt>:exclude_search_params</tt> -- default: nil, Same as :exclude_params but for the :search_params.
|
89
|
-
def searchlogic_url(options = {})
|
90
|
-
search_params = searchlogic_params(options)
|
91
|
-
url = url_for(search_params)
|
92
|
-
literal_param_strings = literal_param_strings(options[:literal_search_params], options[:params_scope].blank? ? "" : "#{options[:params_scope]}")
|
93
|
-
url += (url.last == "?" ? "" : (url.include?("?") ? "&" : "?")) + literal_param_strings.join("&")
|
94
|
-
end
|
95
|
-
|
96
|
-
# When you set up a search form using form_for for remote_form_for searchlogic adds in some *magic* for you.
|
97
|
-
#
|
98
|
-
# Take the instance where a user orders the data by something other than the default, and then does a search. The user would expect the search to remember what the user selected to order the data by, right?
|
99
|
-
# What searchlogic does is add in some hidden fields, somewhere in the page, the represent the searchlogic "state". These are automatically added for you when you use the searchlogic helpers.
|
100
|
-
# Such as: page_links, page_link, order_by_link, per_page_select, etc. So if you are using those you do not need to worry about this helper.
|
101
|
-
#
|
102
|
-
# If for some reason you do not use any of these you need to put the searchlogic state on your page somewhere. Somewhere where the state will *always* be up-to-date, which would be most likely be in the
|
103
|
-
# partial that renders your search results (assuming you are using AJAX). Otherwise when the user starts a new search, the state will be reset. Meaning the order_by, per_page, etc will all be reset.
|
104
|
-
#
|
105
|
-
# === Options
|
106
|
-
# * <tt>:params_scope</tt> -- default: :search, this is the scope in which your search params will be preserved (params[:search]). If you don't want a scope and want your options to be at base leve in params such as params[:page], params[:per_page], etc, then set this to nil.
|
107
|
-
# * <tt>:search_obj</tt> -- default: @#{params_scope}, this is your search object, everything revolves around this. It will try to infer the name from your params_scope. If your params_scope is :search it will try to get @search, etc. If it can not be inferred by this, you need to pass the object itself.
|
108
|
-
def searchlogic_state(options = {})
|
109
|
-
return "" if @added_searchlogic_state
|
110
|
-
add_searchlogic_defaults!(options)
|
111
|
-
html = ""
|
112
|
-
(Search::Base::SPECIAL_FIND_OPTIONS - [:page, :priority_order]).each do |option|
|
113
|
-
value = options[:search_obj].send(option)
|
114
|
-
html += hidden_field(options[:params_scope], option, :value => (option == :order_by ? searchlogic_base64_value(value) : value))
|
115
|
-
end
|
116
|
-
@added_searchlogic_state = true
|
117
|
-
html
|
118
|
-
end
|
119
|
-
|
120
|
-
private
|
121
|
-
# Adds default options for all helper methods.
|
122
|
-
def add_searchlogic_defaults!(options)
|
123
|
-
options[:params_scope] = :search unless options.has_key?(:params_scope)
|
124
|
-
options[:search_obj] ||= instance_variable_get("@#{options[:params_scope]}")
|
125
|
-
raise(ArgumentError, "@search object could not be inferred, please specify: :search_obj => @search or :params_scope => :search_obj_name") unless options[:search_obj].is_a?(Searchlogic::Search::Base)
|
126
|
-
options
|
127
|
-
end
|
128
|
-
|
129
|
-
# Adds default options for all control type helper methods.
|
130
|
-
def add_searchlogic_control_defaults!(options)
|
131
|
-
add_searchlogic_defaults!(options)
|
132
|
-
options[:html] ||= {}
|
133
|
-
options
|
134
|
-
end
|
135
|
-
|
136
|
-
def searchlogic_add_class!(html_options, new_class)
|
137
|
-
new_class = new_class.to_s
|
138
|
-
html_options[:class] ||= ""
|
139
|
-
classes = html_options[:class].split(" ")
|
140
|
-
classes << new_class unless classes.include?(new_class)
|
141
|
-
html_options[:class] = classes.join(" ")
|
142
|
-
end
|
143
|
-
|
144
|
-
def searchlogic_base64_value(order_by)
|
145
|
-
case order_by
|
146
|
-
when String, Symbol
|
147
|
-
order_by
|
148
|
-
when Array, Hash
|
149
|
-
[Marshal.dump(order_by)].pack("m")
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def searchlogic_ordering_by?(order_by, options)
|
154
|
-
stringified_search_order_by = deep_stringify(options[:search_obj].order_by)
|
155
|
-
stringified_order_by = deep_stringify(order_by)
|
156
|
-
(options[:search_obj].order_by.blank? && options[:search_obj].klass.primary_key == stringified_order_by) || stringified_search_order_by == stringified_order_by
|
157
|
-
end
|
158
|
-
|
159
|
-
def literal_param_strings(literal_params, prefix)
|
160
|
-
param_strings = []
|
161
|
-
|
162
|
-
literal_params.each do |k, v|
|
163
|
-
param_string = prefix.blank? ? k.to_s : "#{prefix}[#{k}]"
|
164
|
-
case v
|
165
|
-
when Hash
|
166
|
-
literal_param_strings(v, param_string).each do |literal_param_string|
|
167
|
-
param_strings << literal_param_string
|
168
|
-
end
|
169
|
-
else
|
170
|
-
param_strings << (CGI.escape(param_string) + "=#{v}")
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
param_strings
|
175
|
-
end
|
176
|
-
|
177
|
-
def deep_stringify(obj)
|
178
|
-
case obj
|
179
|
-
when String
|
180
|
-
obj
|
181
|
-
when Symbol
|
182
|
-
obj.to_s
|
183
|
-
when Array
|
184
|
-
obj.collect { |item| deep_stringify(item) }
|
185
|
-
when Hash
|
186
|
-
new_obj = {}
|
187
|
-
obj.each { |key, value| new_obj[key.to_s] = deep_stringify(value) }
|
188
|
-
new_obj
|
189
|
-
else
|
190
|
-
obj
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
ActionController::Base.helper(Searchlogic::Helpers::Utilities) if defined?(ActionController)
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Modifiers
|
3
|
-
class Base
|
4
|
-
class << self
|
5
|
-
# A convenience method for the name of this modifier
|
6
|
-
def modifier_name
|
7
|
-
name.split("::").last.underscore
|
8
|
-
end
|
9
|
-
|
10
|
-
# The various names for the modifier. The first in the array is the "main" name, the rest are just aliases to the "main" name
|
11
|
-
def modifier_names
|
12
|
-
[modifier_name]
|
13
|
-
end
|
14
|
-
|
15
|
-
# The method in the connection adapter that creates the SQL for the modifier
|
16
|
-
def adapter_method_name
|
17
|
-
"#{modifier_name}_sql"
|
18
|
-
end
|
19
|
-
|
20
|
-
# The type of value returned from the SQL. A class the extends this MUST define this method.
|
21
|
-
def return_type
|
22
|
-
raise "You did not specify a return type for the #{modifier_name} modifier. Please specify if it is an :integer, :string, etc."
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|