searchgasm 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +10 -1
- data/Manifest +2 -2
- data/README.rdoc +2 -17
- data/Rakefile +1 -1
- data/lib/searchgasm/active_record/associations.rb +0 -20
- data/lib/searchgasm/active_record/base.rb +16 -44
- data/lib/searchgasm/conditions/base.rb +5 -4
- data/lib/searchgasm/core_ext/hash.rb +13 -0
- data/lib/searchgasm/helpers/control_types/link.rb +8 -10
- data/lib/searchgasm/helpers/control_types/links.rb +4 -4
- data/lib/searchgasm/helpers/control_types/select.rb +4 -9
- data/lib/searchgasm/helpers/utilities.rb +55 -31
- data/lib/searchgasm/search/base.rb +17 -11
- data/lib/searchgasm/search/conditions.rb +14 -3
- data/lib/searchgasm/search/ordering.rb +16 -16
- data/lib/searchgasm/search/searching.rb +32 -0
- data/lib/searchgasm/version.rb +2 -2
- data/lib/searchgasm.rb +2 -1
- data/searchgasm.gemspec +9 -6
- data/test/fixtures/user_groups.yml +13 -0
- data/test/test_active_record_associations.rb +56 -36
- data/test/test_active_record_base.rb +46 -56
- data/test/test_condition_base.rb +43 -20
- data/test/test_condition_types.rb +0 -11
- data/test/test_conditions_base.rb +113 -120
- data/test/test_conditions_protection.rb +6 -17
- data/test/test_config.rb +2 -11
- data/test/test_helper.rb +38 -7
- data/test/test_search_base.rb +7 -18
- data/test/test_search_conditions.rb +26 -14
- data/test/test_search_ordering.rb +0 -11
- data/test/test_search_pagination.rb +0 -11
- data/test/test_search_protection.rb +0 -11
- metadata +8 -5
- data/lib/searchgasm/shared/searching.rb +0 -43
- data/test/text_config.rb +0 -1
@@ -1,43 +0,0 @@
|
|
1
|
-
module Searchgasm
|
2
|
-
module Shared
|
3
|
-
# = Searchgasm Searching
|
4
|
-
#
|
5
|
-
# Implements searching functionality for searchgasm. Searchgasm::Search::Base and Searchgasm::Conditions::Base can both search and include
|
6
|
-
# this module.
|
7
|
-
module Searching
|
8
|
-
# Use these methods just like you would in ActiveRecord
|
9
|
-
SEARCH_METHODS = [:all, :find, :first]
|
10
|
-
CALCULATION_METHODS = [:average, :calculate, :count, :maximum, :minimum, :sum]
|
11
|
-
|
12
|
-
def self.included(klass)
|
13
|
-
klass.class_eval do
|
14
|
-
attr_accessor :scope
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
(SEARCH_METHODS + CALCULATION_METHODS).each do |method|
|
19
|
-
class_eval <<-"end_eval", __FILE__, __LINE__
|
20
|
-
def #{method}(*args)
|
21
|
-
find_options = {}
|
22
|
-
options = args.extract_options!
|
23
|
-
with_scopes = [scope, (self.class < Searchgasm::Conditions::Base ? {:conditions => sanitize} : sanitize(#{SEARCH_METHODS.include?(method)})), options].compact
|
24
|
-
with_scopes.each do |with_scope|
|
25
|
-
klass.send(:with_scope, :find => find_options) do
|
26
|
-
klass.send(:with_scope, :find => with_scope) do
|
27
|
-
find_options = klass.send(:scope, :find)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
if self.class < Searchgasm::Search::Base
|
33
|
-
(find_options.symbolize_keys.keys - #{SEARCH_METHODS.include?(method) ? "Search::Base::AR_FIND_OPTIONS" : "Search::Base::AR_CALCULATIONS_OPTIONS"}).each { |option| find_options.delete(option) }
|
34
|
-
end
|
35
|
-
|
36
|
-
args << find_options
|
37
|
-
klass.#{method}(*args)
|
38
|
-
end
|
39
|
-
end_eval
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/test/text_config.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# need to test that setting config doesn't mess up regular searches, only protected ones, etc
|