scope_composer 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTJjNjcxMTFlZGY3OTAwMzE2MjRiMjZlNzcwODA5YmZlODU3MTM0ZA==
4
+ MWZiN2E2N2U1MTQ2YjQ3MTY3MGI5ZWE4NTQ4MTMwYjIxZmU1MTQ5Mw==
5
5
  data.tar.gz: !binary |-
6
- ODhiMTAzMTA3ZTQyOWY4M2U3ZjJlYWRiNzZjYjQwODgyOGM2ZjJlMw==
6
+ NmY5ZTUyYjE1MzE0YjM2ZjNmM2NiYjgyZDU2NTY5NmQxNDU5NmFlNA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MDg5MjQ0OTA5MThkYmNiOTU3NjJkYWMwNjA4ZTcyMDk2NWM3NjcxOTVmZTAy
10
- YWIwN2Y0Y2E0Yjg5Y2VlNDE1YWU3MzhjYmNhYWFjZjAyMzkyNjM4NWMyYjA0
11
- MmJjMWQ3ODQ0YmVhY2E0NzcxYmY1OTFmOTBiZGFiZWRlNGFmOGI=
9
+ Njg2NjA0MDVhZDAxOGE2ZWFlNzNmZTJkMmM4MTUwOTZlY2E3NTdkODdhYTAw
10
+ Yjk5NjE1N2FhYmZkMWE4ZDVmYzAxM2M3Njk3YzdlZWU0MTY0OGZjMTJiYWM2
11
+ M2I3NTBlYjVjZTc0MDAwNjYwY2RjYWI2YTUwMzNhNzM0ZjA0ZmU=
12
12
  data.tar.gz: !binary |-
13
- MTk5M2I3MmFjMTFiNDBjNmY0NDY2MTFkMzllN2VjODk5NGRlZGY2NzNiZGI2
14
- Yzg3ZDVlYjAwNzY1YzdmMTYxMjg4Mzg5MzkxYTkzN2FmZDMxZWNhNjU5YzMy
15
- MGZmZTEwODkxMGViZDYzNmM0ODk5MWRkNWZkMDhhYThhZjVkNTI=
13
+ NGY5NDg4ZTM1ZWZkZThhYTQ0YzAxM2EyYTRmZWI5NzMzMGRjNGQ0OGMwMjI2
14
+ ZTVhN2IzZGZjNjY5MjcyZDVjMTE3ZWE3YzQyYmQyMWE4ZWQ5OTU4ZmEyZjBm
15
+ Zjg2Njc1YWExYmI1MjA0OWU0NTAzYjU5ZGRiYmFlNzMzODg3OGM=
data/UPGRADE.md CHANGED
@@ -1,7 +1,13 @@
1
+ ## 0.3.1
2
+
3
+ * scope given multiple arguments will assign an array instead of a value
4
+
5
+
1
6
  ## 0.3.0
2
7
 
3
8
  * it stores scope_attributes seperately from attributes
4
9
 
10
+
5
11
  ## 0.2.0
6
12
 
7
13
  * subject#where should return self
@@ -116,11 +116,11 @@ class Scope
116
116
  # define method
117
117
  define_method(name) do |*args|
118
118
  # init
119
- value = args.first
119
+ values = args.count == 1 ? args.first : args
120
120
  # if no value is given, act as a getter
121
- return scope_attributes[name] if value.nil?
121
+ return scope_attributes[name] if values.nil?
122
122
  # otherwise set the value
123
- scope_attributes[name] = value
123
+ scope_attributes[name] = values
124
124
  # and return self for chaining
125
125
  return self
126
126
  end
@@ -1,3 +1,3 @@
1
1
  module ScopeComposer
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -11,6 +11,7 @@ describe ScopeComposer::Model do
11
11
  scope_helper :helper_method, ->(t){ 'hi' }
12
12
 
13
13
  scope_composer_for :search
14
+ search_scope :select
14
15
  search_scope :limit
15
16
  search_scope :offset, prefix: true
16
17
  search_helper :tester, ->(t){ t.to_i }
@@ -43,6 +44,13 @@ describe ScopeComposer::Model do
43
44
  its(:scope_attributes){ should eq({ limit: 10 }) }
44
45
  its(:attributes){ should eq({}) }
45
46
 
47
+ describe "#select" do
48
+ before(:each){ scope.select(:key1, :key2, :key3) }
49
+
50
+ its(:scope_attributes){ should eq({ limit: 10, select: [:key1, :key2, :key3] }) }
51
+
52
+ end
53
+
46
54
  describe "#where" do
47
55
  before(:each){ scope.where( id: 20 ) }
48
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scope_composer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hilscher