rom-factory 0.8.0 → 0.9.0

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: d518c3e2f7f686c9366ef1c54ba7a2c33d1858fd3507dde56b49a1f1e9c49efd
4
- data.tar.gz: 7fdf505e789b85006f9dd639b1bc15b1ed76a2129144dd965494ab0853693ffa
3
+ metadata.gz: 405ffd84ef6d6c604dc925be2d885f9639986893281dea271ae65584505e40a3
4
+ data.tar.gz: 78e65374754604602d984aba6a0b7374041b5972fcd464187f6d0ec2a7a919a5
5
5
  SHA512:
6
- metadata.gz: 90d96b038566692c001c2eabdee291276ec604910db01343b912d4c56690a6564278183f1315d87d6de42dc7716a4a3f26518dcff6f1ffcad1f3301f1553a737
7
- data.tar.gz: 2ea5c2473d2a35b109978079f8ac71c3ea375b19643b787bc0c71b9549b03cfb3e09173fb33b30b1465ff85defabe588a075fc4e6857040d77fdc59fec9c04fe
6
+ metadata.gz: c787c81d9545fa094c84751dd81e0f2fcb4d66de479354f9fe44dd7b6df8442bdf4c913998cad3584ad3ff2e4741603edcfb1508e9eec3067c32686f1889ef81
7
+ data.tar.gz: 8128cb92776ecedc10e7da0d5e5213f4f4bb6b8663d3ace72a19cd2cf985cd78d85744119d3e61b7dfc4ac44478a912966fd9c14a59b48f463140d164a81827f
@@ -1,4 +1,12 @@
1
- ## 0.8.0 to-be-released
1
+ ## 0.9.0 2019-08-12
2
+
3
+ ### Added
4
+
5
+ * When attributes hash includes unknown attributes, a `ROM::Factory::UnknownAttributeError` will be raised (@rawburt)
6
+
7
+ [Compare v0.8.0...v0.9.0](https://github.com/rom-rb/rom-factory/compare/v0.8.0...v0.9.0)
8
+
9
+ ## 0.8.0 2019-04-24
2
10
 
3
11
  ### Fixed
4
12
 
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
8
8
 
9
9
  gem 'rake', '~> 12.0'
10
10
  gem 'rspec', '~> 3.0'
11
+ gem 'faker', '<= 1.9'
11
12
 
12
13
  group :test do
13
14
  gem 'rom-sql', '~> 3.0'
@@ -33,6 +33,7 @@ module ROM::Factory
33
33
 
34
34
  # @api private
35
35
  def struct(*traits, **attrs)
36
+ validate_keys(traits, attrs)
36
37
  tuple_evaluator.struct(*traits, attrs)
37
38
  end
38
39
  alias_method :create, :struct
@@ -56,5 +57,14 @@ module ROM::Factory
56
57
  def relation
57
58
  tuple_evaluator.relation
58
59
  end
60
+
61
+ # @api private
62
+ def validate_keys(traits, tuple)
63
+ schema_keys = relation.schema.attributes.map(&:name)
64
+ assoc_keys = tuple_evaluator.assoc_names(traits)
65
+ unknown_keys = tuple.keys - schema_keys - assoc_keys
66
+
67
+ raise UnknownFactoryAttributes, unknown_keys unless unknown_keys.empty?
68
+ end
59
69
  end
60
70
  end
@@ -23,6 +23,7 @@ module ROM
23
23
  # @api private
24
24
  def create(*traits, **attrs)
25
25
  tuple = tuple(*traits, attrs)
26
+ validate_keys(traits, attrs)
26
27
  persisted = persist(tuple)
27
28
 
28
29
  if tuple_evaluator.has_associations?(traits)
@@ -7,5 +7,11 @@ module ROM
7
7
  super("Factory +#{name}+ not defined")
8
8
  end
9
9
  end
10
+
11
+ class UnknownFactoryAttributes < StandardError
12
+ def initialize(attrs)
13
+ super("Unknown attributes: #{attrs.join(', ')}")
14
+ end
15
+ end
10
16
  end
11
17
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ROM
4
4
  module Factory
5
- VERSION = '0.8.0'
5
+ VERSION = '0.9.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janis Miezitis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-04-24 00:00:00.000000000 Z
12
+ date: 2019-08-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dry-configurable