associationist 0.1.4 → 0.1.8
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 +5 -5
- data/lib/associationist/associations/collection_association.rb +8 -0
- data/lib/associationist/associations/preloader/singular_association.rb +4 -2
- data/lib/associationist/builder/collection_association.rb +6 -1
- data/lib/associationist/builder/singular_association.rb +14 -1
- data/lib/associationist/reflection/collection_reflection.rb +1 -1
- data/lib/associationist/reflection/singular_reflection.rb +1 -1
- data/lib/associationist/version.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8685abcebf828aabc6f3337bfcbf4baac04c73dc847b5a235933c5b2e3e8e487
|
4
|
+
data.tar.gz: 21983405667e166041b1ad1670cdf399813d83579c4408ba0aa0c9e3d5dd8359
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d77f497b70cf83ff9912af6cd80c3608de1593461fe0c1f30dbcfe459fe17fd118b94383ca78a37d38fbab5d5e1d2eb697fbbb8f0938e88b6ac7b78f62b180e
|
7
|
+
data.tar.gz: 71f89b2f935278cf9d044152d6fa92895af98e05a9f49523d0031ab39d0dca1d81f7546bfdbbf338c124c187d94100c10f6981e18451acb317e09c2063465f4e
|
@@ -27,6 +27,14 @@ module Associationist
|
|
27
27
|
true
|
28
28
|
end
|
29
29
|
end
|
30
|
+
|
31
|
+
def self.define_writers(mixin, name)
|
32
|
+
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
|
33
|
+
def #{name}=(value)
|
34
|
+
raise "Virtual associations are read-only."
|
35
|
+
end
|
36
|
+
CODE
|
37
|
+
end
|
30
38
|
end
|
31
39
|
end
|
32
40
|
end
|
@@ -2,12 +2,13 @@ module Associationist
|
|
2
2
|
module Associations
|
3
3
|
module Preloader
|
4
4
|
class SingularAssociation
|
5
|
-
def initialize klass, owners, reflection, preload_scope
|
5
|
+
def initialize klass, owners, reflection, preload_scope, associate_by_default = true
|
6
6
|
@owners = owners
|
7
7
|
@reflection = reflection
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
# handle >= 6.0
|
11
|
+
def run preloader = nil
|
11
12
|
case
|
12
13
|
when @reflection.config.preloader_proc
|
13
14
|
@reflection.config.preloader_proc.call(@owners).each do |record, value|
|
@@ -29,6 +30,7 @@ module Associationist
|
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
33
|
+
self
|
32
34
|
end
|
33
35
|
|
34
36
|
def preloaded_records
|
@@ -18,7 +18,12 @@ module Associationist
|
|
18
18
|
|
19
19
|
validate_options(options)
|
20
20
|
|
21
|
-
|
21
|
+
case
|
22
|
+
when ActiveRecord.version >= Gem::Version.new('6.0.0')
|
23
|
+
scope = build_scope(scope)
|
24
|
+
else
|
25
|
+
scope = build_scope(scope, extension)
|
26
|
+
end
|
22
27
|
Reflection::CollectionReflection.new(name, scope, options, model)
|
23
28
|
end
|
24
29
|
end
|
@@ -25,10 +25,23 @@ module Associationist
|
|
25
25
|
raise ArgumentError, "association names must be a Symbol" unless name.kind_of?(Symbol)
|
26
26
|
|
27
27
|
validate_options(options)
|
28
|
-
|
28
|
+
case
|
29
|
+
when ActiveRecord.version >= Gem::Version.new('6.0.0')
|
30
|
+
scope = build_scope(scope)
|
31
|
+
else
|
32
|
+
scope = build_scope(scope, extension)
|
33
|
+
end
|
29
34
|
Reflection::SingularReflection.new(name, scope, options, model)
|
30
35
|
end
|
31
36
|
|
37
|
+
def self.define_writers(mixin, name)
|
38
|
+
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
|
39
|
+
def #{name}=(value)
|
40
|
+
raise "Virtual associations are read-only."
|
41
|
+
end
|
42
|
+
CODE
|
43
|
+
end
|
44
|
+
|
32
45
|
end
|
33
46
|
end
|
34
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: associationist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- onyxblade
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '5.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '6'
|
22
|
+
version: '6.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '5.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '6'
|
32
|
+
version: '6.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: pry
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,7 +104,7 @@ files:
|
|
104
104
|
- lib/associationist/reflection/collection_reflection.rb
|
105
105
|
- lib/associationist/reflection/singular_reflection.rb
|
106
106
|
- lib/associationist/version.rb
|
107
|
-
homepage: https://github.com/
|
107
|
+
homepage: https://github.com/onyxblade/associationist
|
108
108
|
licenses:
|
109
109
|
- MIT
|
110
110
|
metadata: {}
|
@@ -123,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
|
127
|
-
rubygems_version: 2.5.2.3
|
126
|
+
rubygems_version: 3.2.15
|
128
127
|
signing_key:
|
129
128
|
specification_version: 4
|
130
129
|
summary: ''
|