searchgasm 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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