assignable_values 0.18.0 → 0.18.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35aa591ab2d6741bce223c55269b850a758f5f4f5cb63af013573bd9b54ebc26
4
- data.tar.gz: adf1444e4391df0fd44367403b76fa79afb00d3035130a94a7b613e008e0a6e2
3
+ metadata.gz: 933681c08828de5d892b6d4a200a6376b0de7b700c55bc824124f1b0114501fc
4
+ data.tar.gz: 1e1fa1a8bb6999ca7da4bf1d91d9ed1163e4770904c0f8eeb8c63b3f6c207575
5
5
  SHA512:
6
- metadata.gz: f8bc245b41f780b768b8e3a5a3420278ac7123cddc90952785f8999ed12d4724c84fdef0876be7fa9cb756818662504b78499049745cc92bf71effd581d4eab0
7
- data.tar.gz: c5078834cb387afe0c2b320aef6b70286e1959c873b6b8ec31cd8e5c8bfe308c72b36de5279729ec87a2ab0f9839a7c24d1417d9b13cde174f513b0971fd67eb
6
+ metadata.gz: be6eb8de9809e1398ea1e4e13256a2118acc319a306ec144c9b89723c4ed2c677a83c98898844f0a899c4144f9b85de8e9a9d9ea0110d5b70c5e366862db82e1
7
+ data.tar.gz: 38dc638bc04ae0bcb3317e3886f22aacb2c784e9909a316e2d734795f4da40d7faaee6e931451daa42ac40975350eb5e27e6c9c192104238e20872a270da6972
data/CHANGELOG.md CHANGED
@@ -14,6 +14,11 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
14
14
 
15
15
 
16
16
 
17
+ ## 0.18.1 - 2023-09-06
18
+
19
+ ### Compatible changes
20
+
21
+ - Calling `assignable_values_for` with unsupported options will raise an error.
17
22
 
18
23
  ## 0.18.0 - 2023-01-24
19
24
 
data/Gemfile.5.0.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assignable_values (0.18.0)
4
+ assignable_values (0.18.1)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
data/Gemfile.5.1.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assignable_values (0.18.0)
4
+ assignable_values (0.18.1)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
data/Gemfile.5.1.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assignable_values (0.18.0)
4
+ assignable_values (0.18.1)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
data/Gemfile.6.1.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assignable_values (0.18.0)
4
+ assignable_values (0.18.1)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
data/Gemfile.7.0.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assignable_values (0.18.0)
4
+ assignable_values (0.18.1)
5
5
  activerecord (>= 2.3)
6
6
 
7
7
  GEM
@@ -5,11 +5,24 @@ module AssignableValues
5
5
 
6
6
  attr_reader :model, :property, :options, :values, :default, :secondary_default
7
7
 
8
+ SUPPORTED_OPTIONS = [
9
+ :allow_blank,
10
+ :decorate,
11
+ :default,
12
+ :include_old_value,
13
+ :message,
14
+ :multiple,
15
+ :secondary_default,
16
+ :through,
17
+ ].freeze
18
+ private_constant :SUPPORTED_OPTIONS
19
+
8
20
  def initialize(model, property, options, &values)
9
21
  @model = model
10
22
  @property = property
11
23
  @options = options
12
24
  @values = values
25
+ validate_supported_options!
13
26
  ensure_values_given
14
27
  setup_default
15
28
  define_assignable_values_method
@@ -274,8 +287,14 @@ module AssignableValues
274
287
  @values or @options[:through] or raise NoValuesGiven, 'You must supply the list of assignable values by either a block or :through option'
275
288
  end
276
289
 
290
+ def validate_supported_options!
291
+ unsupported_options = @options.keys - SUPPORTED_OPTIONS
292
+ if unsupported_options.any?
293
+ raise UnsupportedOption,
294
+ "The following options are not supported: #{unsupported_options.map { |o| ":#{o}" }.join(', ')}"
295
+ end
296
+ end
277
297
  end
278
298
  end
279
299
  end
280
300
  end
281
-
@@ -3,4 +3,5 @@ module AssignableValues
3
3
  class DelegateUnavailable < Error; end
4
4
  class NoValuesGiven < Error; end
5
5
  class NoDefault < Error; end
6
+ class UnsupportedOption < Error; end
6
7
  end
@@ -1,3 +1,3 @@
1
1
  module AssignableValues
2
- VERSION = '0.18.0'
2
+ VERSION = '0.18.1'
3
3
  end
@@ -21,6 +21,14 @@ describe AssignableValues::ActiveRecord do
21
21
  end.to raise_error(AssignableValues::NoValuesGiven)
22
22
  end
23
23
 
24
+ it 'should raise an error when called with unsupported options' do
25
+ expect do
26
+ Song.disposable_copy do
27
+ assignable_values_for :genre, unsupported_option: 42
28
+ end
29
+ end.to raise_error(AssignableValues::UnsupportedOption, 'The following options are not supported: :unsupported_option')
30
+ end
31
+
24
32
  context 'when validating virtual attributes' do
25
33
 
26
34
  before :each do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assignable_values
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-24 00:00:00.000000000 Z
11
+ date: 2023-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  requirements: []
93
- rubygems_version: 3.4.1
93
+ rubygems_version: 3.4.14
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Restrict the values assignable to ActiveRecord attributes or associations