itrigga-param_fu 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -11,6 +11,7 @@ group :development do
11
11
  gem "bundler", "~> 1.0.0"
12
12
  gem "jeweler", "~> 1.6.4"
13
13
  gem "rcov", ">= 0"
14
+ gem "itrigga-core_ext", ">=0.2.4"
14
15
  end
15
16
 
16
17
  group :test do
data/Gemfile.lock CHANGED
@@ -2,6 +2,7 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  git (1.2.5)
5
+ itrigga-core_ext (0.2.4)
5
6
  jeweler (1.6.4)
6
7
  bundler (~> 1.0)
7
8
  git (>= 1.2.5)
@@ -19,6 +20,7 @@ PLATFORMS
19
20
 
20
21
  DEPENDENCIES
21
22
  bundler (~> 1.0.0)
23
+ itrigga-core_ext (>= 0.2.4)
22
24
  jeweler (~> 1.6.4)
23
25
  rcov
24
26
  rspec (= 1.3.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.4.0
@@ -1,5 +1,8 @@
1
+ require 'itrigga/core_ext/string'
2
+
1
3
  module Trigga
2
4
  module ParamFu
5
+
3
6
  def self.included(base)
4
7
  base.extend(AllMethods)
5
8
  base.send(:include, AllMethods)
@@ -105,7 +108,7 @@ module Trigga
105
108
  c = {:where=>[], :values=>[]}
106
109
  if opts[param_name]
107
110
  c[:where] << "( #{model_class.table_name}.#{definition[:field_name] || param_name.to_s} #{definition[:operator] || '='} (?) )"
108
- c[:values] << opts[param_name]
111
+ c[:values] << ( definition[:operator] =~ /\blike\b/i ? opts[param_name].to_active_record_condition : opts[param_name] )
109
112
  end
110
113
  c
111
114
  end
@@ -240,6 +240,16 @@ describe ::Trigga::ParamFu do
240
240
  end
241
241
  end
242
242
 
243
+ context "when the given :operator matches 'like'" do
244
+ before(:each) do
245
+ @definition[:operator] = " LIKE "
246
+ end
247
+
248
+ it "should add the corresponding value, converted to a like condition, to the :values key" do
249
+ Tester.parse_field_definition( @params, @model_class, @param_name, @definition )[:values].should == ['%param_1%value%']
250
+ end
251
+ end
252
+
243
253
  it "should add the corresponding value to the :values key" do
244
254
  Tester.parse_field_definition( @params, @model_class, @param_name, @definition )[:values].should == ['param_1 value']
245
255
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itrigga-param_fu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Al Davidson
@@ -97,6 +97,22 @@ dependencies:
97
97
  - 0
98
98
  version: "0"
99
99
  requirement: *id005
100
+ - !ruby/object:Gem::Dependency
101
+ prerelease: false
102
+ name: itrigga-core_ext
103
+ type: :development
104
+ version_requirements: &id006 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 31
110
+ segments:
111
+ - 0
112
+ - 2
113
+ - 4
114
+ version: 0.2.4
115
+ requirement: *id006
100
116
  description: Validates parameters to methods are present and are the required types
101
117
  email: support@itrigga.com
102
118
  executables: []