itrigga-param_fu 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -34,14 +34,14 @@ module Trigga
34
34
  end
35
35
 
36
36
  def id_or_name_condition(table, val)
37
- condition = {:where => [], :values=>[]}
37
+ condition = {:where => nil, :values=>nil}
38
38
  unless val.to_s.empty?
39
39
  unless val.match(/[^0-9]/)
40
- condition[:where] << "#{table}.id = ?"
41
- condition[:values] << val.to_i
40
+ condition[:where] = "#{table}.id = ?"
41
+ condition[:values] = val.to_i
42
42
  else
43
- condition[:where] << "#{table}.name LIKE ?"
44
- condition[:values] << "#{'%' + val.gsub(/\(\d+\)/,"") + '%'}"
43
+ condition[:where] = "#{table}.name LIKE ?"
44
+ condition[:values] = "#{'%' + val.gsub(/\(\d+\)/,"") + '%'}"
45
45
  end
46
46
  end
47
47
  condition
@@ -117,21 +117,21 @@ describe ::Trigga::ParamFu do
117
117
 
118
118
  context "when given a string value" do
119
119
  it "should include '(table).name like ?' in the where clause" do
120
- Tester.id_or_name_condition('mymodel', 'string_value')[:where][0].should =~ /mymodel\.name\s*like\s*\?/i
120
+ Tester.id_or_name_condition('mymodel', 'string_value')[:where].should =~ /mymodel\.name\s*like\s*\?/i
121
121
  end
122
122
 
123
123
  it "should include the given value in values, wrapped in wildcard markers" do
124
- Tester.id_or_name_condition('mymodel', 'string_value')[:values][0].should == '%string_value%'
124
+ Tester.id_or_name_condition('mymodel', 'string_value')[:values].should == '%string_value%'
125
125
  end
126
126
  end
127
127
  context "when given an integer value" do
128
128
 
129
129
  it "should include '(table).id == ?' in the where clause" do
130
- Tester.id_or_name_condition('mymodel', '2')[:where][0].should =~ /mymodel\.id\s*=\s*\?/i
130
+ Tester.id_or_name_condition('mymodel', '2')[:where].should =~ /mymodel\.id\s*=\s*\?/i
131
131
  end
132
132
 
133
133
  it "should include the given value in values, as an integer" do
134
- Tester.id_or_name_condition('mymodel', '2')[:values][0].should == 2
134
+ Tester.id_or_name_condition('mymodel', '2')[:values].should == 2
135
135
  end
136
136
  end
137
137
  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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Al Davidson