duck_chain 1.1.1 → 1.1.2
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/lib/duck_chain/toolset.rb +18 -14
- 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: 27f1bbe0a02c0a8cf4b2e8259aefc4dfc7eab511
|
4
|
+
data.tar.gz: 384b5cad977fa280087b717782d4f69d8765c6ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2018bc688697f81a82dee75e2fdfa7a142ced7bc9f461baebb7b636703ec2327b16d03af5e4a0a9dc3344a6d4b1e0e94fdf1214805cdc27d155d31f272b9d282
|
7
|
+
data.tar.gz: 420db6290a3d620da329d9424f1016dba8fc91a39ea0d4da0a46d123ce9acf08772d0cb6727fc84c507e01793687f555337b2416cea2356562cf3dcb8f156bb3
|
data/CHANGELOG.rdoc
CHANGED
data/lib/duck_chain/toolset.rb
CHANGED
@@ -5,6 +5,10 @@ module DuckChain
|
|
5
5
|
def self.set_as_array(value)
|
6
6
|
value.is_a?(Array) ? value : [value]
|
7
7
|
end
|
8
|
+
|
9
|
+
def self.col_full_name(quoted_table_name, m)
|
10
|
+
"#{quoted_table_name}.#{m}"
|
11
|
+
end
|
8
12
|
|
9
13
|
# Creates 'eq' class methods for the model
|
10
14
|
# Ex:: Post.title_eq("Why do my feet smell?")
|
@@ -25,9 +29,9 @@ module DuckChain
|
|
25
29
|
['eq','equals','is','in'].each do |suffix|
|
26
30
|
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term|
|
27
31
|
if search_term.is_a?(Array) || search_term.is_a?(Range)
|
28
|
-
where(["#{m} IN (?)", search_term])
|
32
|
+
where(["#{Toolset.col_full_name(quoted_table_name, m)} IN (?)", search_term])
|
29
33
|
else
|
30
|
-
where(["#{m} = ?", search_term])
|
34
|
+
where(["#{Toolset.col_full_name(quoted_table_name, m)} = ?", search_term])
|
31
35
|
end
|
32
36
|
}
|
33
37
|
)
|
@@ -36,9 +40,9 @@ module DuckChain
|
|
36
40
|
['neq','not_equal','is_not','does_not_equal','not_in'].each do |suffix|
|
37
41
|
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term|
|
38
42
|
if search_term.is_a?(Array) || search_term.is_a?(Range)
|
39
|
-
where(["#{m} NOT IN (?)", search_term])
|
43
|
+
where(["#{Toolset.col_full_name(quoted_table_name, m)} NOT IN (?)", search_term])
|
40
44
|
else
|
41
|
-
where(["#{m} != ?", search_term])
|
45
|
+
where(["#{Toolset.col_full_name(quoted_table_name, m)} != ?", search_term])
|
42
46
|
end
|
43
47
|
}
|
44
48
|
)
|
@@ -57,13 +61,13 @@ module DuckChain
|
|
57
61
|
# * not_end_with
|
58
62
|
def self.create_like_methods(model_attributes)
|
59
63
|
Toolset.set_as_array(model_attributes).each do |m|
|
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}"])} )
|
64
|
+
self.class.send(:define_method, "#{m}_like", Proc.new{ |search_term| where(["#{Toolset.col_full_name(quoted_table_name, m)} LIKE (?)", "%#{search_term}%"])} )
|
65
|
+
self.class.send(:define_method, "#{m}_begins_with", Proc.new{ |search_term| where(["#{Toolset.col_full_name(quoted_table_name, m)} LIKE (?)", "#{search_term}%"])} )
|
66
|
+
self.class.send(:define_method, "#{m}_ends_with", Proc.new{ |search_term| where(["#{Toolset.col_full_name(quoted_table_name, m)} LIKE (?)", "%#{search_term}"])} )
|
63
67
|
|
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}"])} )
|
68
|
+
self.class.send(:define_method, "#{m}_not_like", Proc.new{ |search_term| where(["#{Toolset.col_full_name(quoted_table_name, m)} NOT LIKE (?)", "%#{search_term}%"])} )
|
69
|
+
self.class.send(:define_method, "#{m}_not_begin_with", Proc.new{ |search_term| where(["#{Toolset.col_full_name(quoted_table_name, m)} NOT LIKE (?)", "#{search_term}%"])} )
|
70
|
+
self.class.send(:define_method, "#{m}_not_end_with", Proc.new{ |search_term| where(["#{Toolset.col_full_name(quoted_table_name, m)} NOT LIKE (?)", "%#{search_term}"])} )
|
67
71
|
end
|
68
72
|
end
|
69
73
|
|
@@ -81,16 +85,16 @@ module DuckChain
|
|
81
85
|
def self.create_range_methods(model_attributes)
|
82
86
|
Toolset.set_as_array(model_attributes).each do |m|
|
83
87
|
['gt','greater_than'].each do |suffix|
|
84
|
-
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where(["#{m} > ?", search_term])} )
|
88
|
+
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where(["#{Toolset.col_full_name(quoted_table_name, m)} > ?", search_term])} )
|
85
89
|
end
|
86
90
|
['gte','greater_than_or_equal_to'].each do |suffix|
|
87
|
-
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where(["#{m} >= ?", search_term])} )
|
91
|
+
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where(["#{Toolset.col_full_name(quoted_table_name, m)} >= ?", search_term])} )
|
88
92
|
end
|
89
93
|
['lt','less_than'].each do |suffix|
|
90
|
-
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where(["#{m} < ?", search_term])} )
|
94
|
+
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where(["#{Toolset.col_full_name(quoted_table_name, m)} < ?", search_term])} )
|
91
95
|
end
|
92
96
|
['lte','less_than_or_equal_to'].each do |suffix|
|
93
|
-
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where(["#{m} <= ?", search_term])} )
|
97
|
+
self.class.send(:define_method, "#{m}_#{suffix}", Proc.new{ |search_term| where(["#{Toolset.col_full_name(quoted_table_name, m)} <= ?", search_term])} )
|
94
98
|
end
|
95
99
|
end
|
96
100
|
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.2
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|