pose 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,12 +57,12 @@ module Pose
57
57
  if options[:result_type] == :ids
58
58
  # Ids requested for result.
59
59
 
60
- if options[:scope].blank?
60
+ if options[:where].blank?
61
61
  # No scope.
62
62
  result[result_class] = ids
63
63
  else
64
64
  # We have a scope.
65
- options[:scope].each do |scope|
65
+ options[:where].each do |scope|
66
66
  query = result_class.select('id').where('id IN (?)', ids).where(scope).to_sql
67
67
  result[result_class] = result_class.connection.select_values(query).map(&:to_i)
68
68
  end
@@ -72,8 +72,8 @@ module Pose
72
72
  # Classes requested for result.
73
73
 
74
74
  result[result_class] = result_class.where(id: ids)
75
- if options.has_key? :scope
76
- options[:scope].each do |scope|
75
+ unless options[:where].blank?
76
+ options[:where].each do |scope|
77
77
  result[result_class] = result[result_class].where('id IN (?)', ids).where(scope)
78
78
  end
79
79
  end
data/lib/pose/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pose
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
3
3
  end
@@ -45,7 +45,6 @@ describe Pose do
45
45
  end
46
46
  end
47
47
 
48
- # TODO(REMOVE).
49
48
  context "in the 'production' environment' do" do
50
49
  before :each do
51
50
  @old_env = Rails.env
@@ -197,7 +196,7 @@ describe Pose do
197
196
  end
198
197
 
199
198
 
200
- describe "'scopes' parameter" do
199
+ describe "'where' parameter" do
201
200
 
202
201
  before :each do
203
202
  @one = FactoryGirl.create :posable_one, text: 'foo one', private: true
@@ -207,27 +206,27 @@ describe Pose do
207
206
 
208
207
  context 'with result type :classes' do
209
208
 
210
- it 'limits the result set by the given scope' do
211
- result = Pose.search 'foo', PosableOne, scope: [ private: true ]
209
+ it 'limits the result set by the given conditions' do
210
+ result = Pose.search 'foo', PosableOne, where: [ private: true ]
212
211
  result[PosableOne].should have(1).item
213
212
  result[PosableOne].should include @one
214
213
  end
215
214
 
216
215
  it 'allows to use the hash syntax for queries' do
217
- result = Pose.search 'foo', PosableOne, scope: [ private: true ]
216
+ result = Pose.search 'foo', PosableOne, where: [ private: true ]
218
217
  result[PosableOne].should have(1).item
219
218
  result[PosableOne].should include @one
220
219
  end
221
220
 
222
221
  it 'allows to use the string syntax for queries' do
223
- result = Pose.search 'foo', PosableOne, scope: [ ['private = ?', true] ]
222
+ result = Pose.search 'foo', PosableOne, where: [ ['private = ?', true] ]
224
223
  result[PosableOne].should have(1).item
225
224
  result[PosableOne].should include @one
226
225
  end
227
226
 
228
- it 'allows to combine several scopes' do
227
+ it 'allows to combine several conditions' do
229
228
  @three = FactoryGirl.create :posable_one, text: 'foo two', private: true
230
- result = Pose.search 'foo', PosableOne, scope: [ {private: true}, ['text = ?', 'foo two'] ]
229
+ result = Pose.search 'foo', PosableOne, where: [ {private: true}, ['text = ?', 'foo two'] ]
231
230
  result[PosableOne].should have(1).item
232
231
  result[PosableOne].should include @three
233
232
  end
@@ -235,8 +234,8 @@ describe Pose do
235
234
 
236
235
  context 'with result type :ids' do
237
236
 
238
- it 'limits the result set by the given scope' do
239
- result = Pose.search 'foo', PosableOne, result_type: :ids, scope: [ private: true ]
237
+ it 'limits the result set by the given condition' do
238
+ result = Pose.search 'foo', PosableOne, result_type: :ids, where: [ private: true ]
240
239
  result[PosableOne].should have(1).item
241
240
  result[PosableOne].should include @one.id
242
241
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pose
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: