assignable_values 0.16.3 → 0.16.4

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
  SHA256:
3
- metadata.gz: 400d27572075ed4ae3361303c97ccb7acf0afb00e63cfdc8e3a667d8da73b874
4
- data.tar.gz: 20e2628282f45a9265d036a0b3ca1078a5bb5532cf06654d05c79bd67c878d96
3
+ metadata.gz: fcf4880911a30c8f39fe52bb5b018226a899b7ea1b6fa0f4b232d54e198abf83
4
+ data.tar.gz: cb52c389c399947480293f65a69d29a2ca6f7ac02de1d743d52a68a1593ba6c2
5
5
  SHA512:
6
- metadata.gz: 0d8d5c406b2829863c62fe04851341667ce4f49cc2e6f3c29e6e58cc4710fe70d123ac7cbc315f56f8fdd1734dcab7c5b9693186bd9b12033db3df03fd686261
7
- data.tar.gz: d0e460d55fa4ce7d26207a239778177f56a4c1dcd73a8f7ee7aa6167094b55b75af84a0a8a9cc9e9e3a371c693b4fb813df16978057e545b4dbaa50415926668
6
+ metadata.gz: c68e65b8fd131d928af7e0ebe32999ade79163cc44059718c8032d17ca2331abfbf1d0c1babe35378f0816edd22ba67e5c6c7ad296348e0608ea492ed7d72383
7
+ data.tar.gz: '08479bf3b543772e9a8810c4cdec60d72979fa152bc445c4e4f7029e5c4909b02c1484f8a40d0044b091e0ece3f068859ebb026ae797912d0d829da9fd682ded'
@@ -8,18 +8,27 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
8
8
 
9
9
  ### Compatible changes
10
10
 
11
+ ## 0.16.4 - 2020-10-15
12
+
13
+ ### Compatible changes
14
+
15
+ - No longer crashes value blocks return `nil`.
16
+
17
+
11
18
  ## 0.16.3 - 2020-10-15
12
19
 
13
20
  ### Compatible changes
14
21
 
15
22
  - No longer crashes when assigning `nil` to an attribute with assignable values that are provided as a scope.
16
23
 
24
+
17
25
  ## 0.16.2 - 2020-10-06
18
26
 
19
27
  ### Compatible changes
20
28
 
21
29
  - when given a scope, do not load all records to memory during validation
22
30
 
31
+
23
32
  ## 0.16.1 - 2019-05-14
24
33
 
25
34
  ### Compatible changes
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assignable_values (0.16.3)
4
+ assignable_values (0.16.4)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assignable_values (0.16.3)
4
+ assignable_values (0.16.4)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assignable_values (0.16.3)
4
+ assignable_values (0.16.4)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assignable_values (0.16.3)
4
+ assignable_values (0.16.4)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assignable_values (0.16.3)
4
+ assignable_values (0.16.4)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assignable_values (0.16.3)
4
+ assignable_values (0.16.4)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assignable_values (0.16.3)
4
+ assignable_values (0.16.4)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
@@ -236,11 +236,17 @@ module AssignableValues
236
236
  end
237
237
 
238
238
  def assignable_values_from_record_or_delegate(record)
239
- if delegate?
239
+ assignable_values = if delegate?
240
240
  assignable_values_from_delegate(record)
241
241
  else
242
242
  record.instance_exec(&@values)
243
243
  end
244
+
245
+ if is_scope?(assignable_values)
246
+ assignable_values
247
+ else
248
+ Array(assignable_values)
249
+ end
244
250
  end
245
251
 
246
252
  def delegate(record)
@@ -1,3 +1,3 @@
1
1
  module AssignableValues
2
- VERSION = '0.16.3'
2
+ VERSION = '0.16.4'
3
3
  end
@@ -808,6 +808,26 @@ describe AssignableValues::ActiveRecord do
808
808
  klass.new.assignable_genres.should == %w[pop rock]
809
809
  end
810
810
 
811
+ it 'returns an array when the value block returns a single value' do
812
+ klass = Song.disposable_copy do
813
+ assignable_values_for :genre do
814
+ 'techno'
815
+ end
816
+ end
817
+
818
+ klass.new.assignable_genres.should == ['techno']
819
+ end
820
+
821
+ it 'returns an empty array when the value block returns nothing' do
822
+ klass = Song.disposable_copy do
823
+ assignable_values_for :genre do
824
+ nil
825
+ end
826
+ end
827
+
828
+ klass.new.assignable_genres.should == []
829
+ end
830
+
811
831
  it 'should prepend a previously saved value to the top of the list, even if is no longer allowed' do
812
832
  klass = Song.disposable_copy do
813
833
  assignable_values_for :genre do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assignable_values
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.3
4
+ version: 0.16.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch