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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 86629357a2894bef36a64e5b1509b7e9a15cef85
4
- data.tar.gz: 943b4fe8c567c4c92d638efe961b8f07146843b9
2
+ SHA256:
3
+ metadata.gz: 8685abcebf828aabc6f3337bfcbf4baac04c73dc847b5a235933c5b2e3e8e487
4
+ data.tar.gz: 21983405667e166041b1ad1670cdf399813d83579c4408ba0aa0c9e3d5dd8359
5
5
  SHA512:
6
- metadata.gz: 0a4b7c799474d1aff7511a8f77f4993b1f7cc70d59a0f83974cef653ae775bdc6636580046ef1ac8a912d90f3524a5ebcc0a26b04557999617354d6240ad5285
7
- data.tar.gz: ad01edca0cd23d63c53165f6fccb5bf22ee41aa16c1e3abbf38e4fdafaae50a629749e36f1c9a56d2fdb41063a611594a3d6531c26dd966076113f1711029f33
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
- def run preloader
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
- scope = build_scope(scope, extension)
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
- scope = build_scope(scope, extension)
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
@@ -6,7 +6,7 @@ module Associationist
6
6
  end
7
7
 
8
8
  def check_eager_loadable!
9
-
9
+ raise "Virtual associations cannot be eager-loaded."
10
10
  end
11
11
 
12
12
  def has_cached_counter?
@@ -6,7 +6,7 @@ module Associationist
6
6
  end
7
7
 
8
8
  def check_eager_loadable!
9
-
9
+ raise "Virtual associations cannot be eager-loaded."
10
10
  end
11
11
 
12
12
  def constructable?
@@ -1,3 +1,3 @@
1
1
  module Associationist
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.8'
3
3
  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
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
- - CicholGricenchos
7
+ - onyxblade
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-10 00:00:00.000000000 Z
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/CicholGricenchos/associationist
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
- rubyforge_project:
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: ''