rom 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/rom/relation/curried.rb +8 -5
- data/lib/rom/version.rb +1 -1
- data/spec/unit/rom/relation/curried_spec.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21823f588a092ca791957a4d3bdb1ca3a78fed7e
|
4
|
+
data.tar.gz: b779976efe0eb2d4ec2e7af273cd67782def6120
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5f1e53320f6da430fed29b9c0619847c47b6e34808445852c362216a04a5354384af47b07b946410aa4fbd51c4925f753ef372c9d1485454c00337fc5ff973f
|
7
|
+
data.tar.gz: 610cc7feec934fb6550b371218d5ebbc901417bfcd25b7d1d6709f8ef91684435b16b4d1da5d5e5405284ed14d0ad8a968a1e0f61e5d30582b17a0afea17d098
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# v3.0.3 2017-02-24
|
2
|
+
|
3
|
+
## Fixed
|
4
|
+
|
5
|
+
* Curried relations when called without args while having some args filled in will return itself (solnic)
|
6
|
+
|
7
|
+
[Compare v3.0.2...v3.0.3](https://github.com/rom-rb/rom/compare/v3.0.2...v3.0.3)
|
8
|
+
|
1
9
|
# v3.0.2 2017-02-24
|
2
10
|
|
3
11
|
## Added
|
@@ -6,6 +14,7 @@
|
|
6
14
|
|
7
15
|
## Fixed
|
8
16
|
|
17
|
+
* Fix output_schema to use Attribute#key rather than canonical names (solnic)
|
9
18
|
* Fix the error message for missing association (flash-gordon)
|
10
19
|
* Curried relation called without any arguments will raise an ArgumentError (solnic)
|
11
20
|
|
data/lib/rom/relation/curried.rb
CHANGED
@@ -28,18 +28,21 @@ module ROM
|
|
28
28
|
|
29
29
|
# Load relation if args match the arity
|
30
30
|
#
|
31
|
-
# @return [Loaded,
|
32
|
-
# @see Lazy#call
|
31
|
+
# @return [Loaded,Curried]
|
33
32
|
#
|
34
33
|
# @api public
|
35
34
|
def call(*args)
|
36
35
|
if arity != -1
|
37
36
|
all_args = curry_args + args
|
38
37
|
|
39
|
-
if
|
40
|
-
Loaded.new(relation.__send__(name.relation, *all_args))
|
41
|
-
elsif args.empty?
|
38
|
+
if all_args.empty?
|
42
39
|
raise ArgumentError, "curried #{relation.class}##{name.to_sym} relation was called without any arguments"
|
40
|
+
end
|
41
|
+
|
42
|
+
if args.empty?
|
43
|
+
self
|
44
|
+
elsif arity == all_args.size
|
45
|
+
Loaded.new(relation.__send__(name.relation, *all_args))
|
43
46
|
else
|
44
47
|
__new__(relation, curry_args: all_args)
|
45
48
|
end
|
data/lib/rom/version.rb
CHANGED
@@ -10,6 +10,10 @@ RSpec.describe ROM::Relation::Curried do
|
|
10
10
|
restrict(name: name)
|
11
11
|
end
|
12
12
|
|
13
|
+
def by_name_and_age(name, age)
|
14
|
+
restrict(name: name, age: age)
|
15
|
+
end
|
16
|
+
|
13
17
|
def find(criteria)
|
14
18
|
restrict(criteria)
|
15
19
|
end
|
@@ -33,6 +37,12 @@ RSpec.describe ROM::Relation::Curried do
|
|
33
37
|
ArgumentError,
|
34
38
|
"curried #{users_relation.class}#by_name relation was called without any arguments")
|
35
39
|
end
|
40
|
+
|
41
|
+
it 'returns self when has curried args and no additional args were provided' do
|
42
|
+
curried = users_relation.by_name_and_age.('Jane')
|
43
|
+
|
44
|
+
expect(curried.().__id__).to be(curried.__id__)
|
45
|
+
end
|
36
46
|
end
|
37
47
|
|
38
48
|
describe '#respond_to?' do
|