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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c00277c8f44c8126393e5cc3e5116cd942877d86
4
- data.tar.gz: 885c76fd153520ac4606b8429598656a78a42551
3
+ metadata.gz: fd46928c5d5d1ee398d1fb04aef1f57616e88c07
4
+ data.tar.gz: 4f35627f52ea073c32832bd361ad4b7ba6271dbc
5
5
  SHA512:
6
- metadata.gz: f3d0673ae48ef702c377cbb7900af3791cf5a97e1691a812e23aa5664bcbcfae4493838fa8265274d110e92ec4ea09b5a296067d76c91406d6f53b9b4b4dfbf7
7
- data.tar.gz: 65d89ccabc5a5ffef387f57102e3847209797ee2670170701efb061552030f3a7f88f7bd09978231743aef07dc92054e8fbc72a8c4863de8cad7fcd8f5d76f12
6
+ metadata.gz: 96f7b2408a2ea2dc44906dea7ef82f904eeaf16ac64bb7b4f1f22f8f95cb0d9c18c47693929966f35fe25ea5dd774f64dda2557d5aba4713ba18606bf6f249e3
7
+ data.tar.gz: 16183a35f800aa5539a0606b9ac990f934795175123843158637fa8d70896e6d20441661e7d58be3be5de28937349c8566087e8ff624265c95c207e891a99fad
@@ -1,3 +1,6 @@
1
+ Version 1.1.1
2
+ * Use string litterals in column names for the conditions (ambisoft)
3
+
1
4
  Version 1.1.0
2
5
  * Added duck_chain_all (cromulus)
3
6
 
@@ -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
 
@@ -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(["? NOT IN (?)", m, search_term])
39
+ where(["#{m} NOT IN (?)", search_term])
40
40
  else
41
- where(["? != ?", m, search_term])
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(["? LIKE (?)", m, "%#{search_term}%"])} )
61
- self.class.send(:define_method, "#{m}_begins_with", Proc.new{ |search_term| where(["? LIKE (?)", m, "#{search_term}%"])} )
62
- self.class.send(:define_method, "#{m}_ends_with", Proc.new{ |search_term| where(["? LIKE (?)", m, "%#{search_term}"])} )
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(["? NOT LIKE (?)", m, "%#{search_term}%"])} )
65
- self.class.send(:define_method, "#{m}_not_begin_with", Proc.new{ |search_term| where(["? NOT LIKE (?)", m, "#{search_term}%"])} )
66
- self.class.send(:define_method, "#{m}_not_end_with", Proc.new{ |search_term| where(["? NOT LIKE (?)", m, "%#{search_term}"])} )
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(['? > ?', m, search_term])} )
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(['? >= ?', m, search_term])} )
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(['? < ?', m, search_term])} )
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(['? <= ?', m, search_term])} )
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
@@ -1,3 +1,3 @@
1
1
  module DuckChain
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
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.0
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-10 00:00:00.000000000 Z
11
+ date: 2013-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord