duck_chain 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +3 -0
- data/README.rdoc +2 -0
- data/lib/duck_chain/toolset.rb +12 -12
- data/lib/duck_chain/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd46928c5d5d1ee398d1fb04aef1f57616e88c07
|
4
|
+
data.tar.gz: 4f35627f52ea073c32832bd361ad4b7ba6271dbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96f7b2408a2ea2dc44906dea7ef82f904eeaf16ac64bb7b4f1f22f8f95cb0d9c18c47693929966f35fe25ea5dd774f64dda2557d5aba4713ba18606bf6f249e3
|
7
|
+
data.tar.gz: 16183a35f800aa5539a0606b9ac990f934795175123843158637fa8d70896e6d20441661e7d58be3be5de28937349c8566087e8ff624265c95c207e891a99fad
|
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
= duck_chain
|
2
2
|
|
3
|
+
=== Note: This gem was originally created for use on Rails 3.0 only to assist with the transition from 2.3.x. However, in theory it should work on later versions of Rails. YMMV.
|
4
|
+
|
3
5
|
== Intro
|
4
6
|
This gem's purpose is to generate basic chainable search methods on models in Rails 3 similar to searchlogic's dynamic named scopes.
|
5
7
|
|
data/lib/duck_chain/toolset.rb
CHANGED
@@ -36,9 +36,9 @@ module DuckChain
|
|
36
36
|
['neq','not_equal','is_not','does_not_equal','not_in'].each do |suffix|
|
37
37
|
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term|
|
38
38
|
if search_term.is_a?(Array) || search_term.is_a?(Range)
|
39
|
-
where(["
|
39
|
+
where(["#{m} NOT IN (?)", search_term])
|
40
40
|
else
|
41
|
-
where(["
|
41
|
+
where(["#{m} != ?", search_term])
|
42
42
|
end
|
43
43
|
}
|
44
44
|
)
|
@@ -57,13 +57,13 @@ module DuckChain
|
|
57
57
|
# * not_end_with
|
58
58
|
def self.create_like_methods(model_attributes)
|
59
59
|
Toolset.set_as_array(model_attributes).each do |m|
|
60
|
-
self.class.send(:define_method, "#{m}_like", Proc.new{ |search_term| where(["
|
61
|
-
self.class.send(:define_method, "#{m}_begins_with", Proc.new{ |search_term| where(["
|
62
|
-
self.class.send(:define_method, "#{m}_ends_with", Proc.new{ |search_term| where(["
|
60
|
+
self.class.send(:define_method, "#{m}_like", Proc.new{ |search_term| where(["#{m} LIKE (?)", "%#{search_term}%"])} )
|
61
|
+
self.class.send(:define_method, "#{m}_begins_with", Proc.new{ |search_term| where(["#{m} LIKE (?)", "#{search_term}%"])} )
|
62
|
+
self.class.send(:define_method, "#{m}_ends_with", Proc.new{ |search_term| where(["#{m} LIKE (?)", "%#{search_term}"])} )
|
63
63
|
|
64
|
-
self.class.send(:define_method, "#{m}_not_like", Proc.new{ |search_term| where(["
|
65
|
-
self.class.send(:define_method, "#{m}_not_begin_with", Proc.new{ |search_term| where(["
|
66
|
-
self.class.send(:define_method, "#{m}_not_end_with", Proc.new{ |search_term| where(["
|
64
|
+
self.class.send(:define_method, "#{m}_not_like", Proc.new{ |search_term| where(["#{m} NOT LIKE (?)", "%#{search_term}%"])} )
|
65
|
+
self.class.send(:define_method, "#{m}_not_begin_with", Proc.new{ |search_term| where(["#{m} NOT LIKE (?)", "#{search_term}%"])} )
|
66
|
+
self.class.send(:define_method, "#{m}_not_end_with", Proc.new{ |search_term| where(["#{m} NOT LIKE (?)", "%#{search_term}"])} )
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -81,16 +81,16 @@ module DuckChain
|
|
81
81
|
def self.create_range_methods(model_attributes)
|
82
82
|
Toolset.set_as_array(model_attributes).each do |m|
|
83
83
|
['gt','greater_than'].each do |suffix|
|
84
|
-
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where([
|
84
|
+
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where(["#{m} > ?", search_term])} )
|
85
85
|
end
|
86
86
|
['gte','greater_than_or_equal_to'].each do |suffix|
|
87
|
-
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where([
|
87
|
+
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where(["#{m} >= ?", search_term])} )
|
88
88
|
end
|
89
89
|
['lt','less_than'].each do |suffix|
|
90
|
-
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where([
|
90
|
+
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where(["#{m} < ?", search_term])} )
|
91
91
|
end
|
92
92
|
['lte','less_than_or_equal_to'].each do |suffix|
|
93
|
-
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where([
|
93
|
+
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where(["#{m} <= ?", search_term])} )
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|
data/lib/duck_chain/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duck_chain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Drake
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|