passive_columns 0.3.2 → 0.3.3

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: 0d9695006ebeabd65f0e14a0677f0161b90a13c2efc08718275a0f3c689f2d05
4
- data.tar.gz: 78f853029324f5c67d042ba402ba469afc0b295f227a8dbc070eecdffcbfa8de
3
+ metadata.gz: a9a4221690fe58e97942823926abe335c1480f4e2a60886d4020d5616fd65cdb
4
+ data.tar.gz: bee747bdd177f3e7f8471ed3150421ef4dfad35e9458513515daa34c72308bf3
5
5
  SHA512:
6
- metadata.gz: 70793175ba5c45e30ac3807329948c75ddb8c48c3d22c861abbbc4dba5229165b58a0c77d899bd88ae1beba811768c485e91bc79ffdcaabdcad4276024e50d82
7
- data.tar.gz: f1a0c0521c4c446453bbf5d675c16e12835a0db2d53276fe8515da9b5d143ee66415364d401536c35733ffb0c3c0023289f4df15f311a28765ac5272cfaf44bd
6
+ metadata.gz: 2c74c6174d74f7075f34eceea98cb0ecf93fa637a4998580e9928b0cc9e3e731f59f1fbbdfff47b5e328ca12cce3143002a31c6ee475f7151f3b4321eff68e27
7
+ data.tar.gz: 4fd85df44dab117a1c032671b7d5b32bb3b4b60f3f73a6006eed17154e2de6b1593d424710e9df68d3855aea2578bacc8d35d80e69bb8bbd8d26164f2447580b
@@ -1,14 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'passive_columns/active_record_relation_extension'
4
- require 'passive_columns/active_record_association_builder_extension'
5
4
 
6
5
  module PassiveColumns # :nodoc:
7
6
  class Railtie < Rails::Railtie # :nodoc:
8
7
  config.to_prepare do |_app|
9
8
  ActiveSupport.on_load(:active_record) do
10
9
  ActiveRecord::Relation.prepend ActiveRecordRelationExtension
11
- ActiveRecord::Associations::Builder::Association.prepend ActiveRecordAssociationBuilderExtension
12
10
  end
13
11
  end
14
12
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PassiveColumns
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passive_columns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Golovin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-10 00:00:00.000000000 Z
11
+ date: 2025-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -91,7 +91,6 @@ files:
91
91
  - README.md
92
92
  - Rakefile
93
93
  - lib/passive_columns.rb
94
- - lib/passive_columns/active_record_association_builder_extension.rb
95
94
  - lib/passive_columns/active_record_relation_extension.rb
96
95
  - lib/passive_columns/loader.rb
97
96
  - lib/passive_columns/railtie.rb
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PassiveColumns
4
- # This module is used to extend the ActiveRecord::Associations::Builder::Association class
5
- # to add a proc with default scope to the association if there is no proc defined.
6
- module ActiveRecordAssociationBuilderExtension
7
- extend ActiveSupport::Concern
8
-
9
- class_methods do
10
- def create_reflection(*)
11
- super.tap do |res|
12
- next if res.polymorphic?
13
- next unless _klass_has_passive_columns(res) && res.scope.nil?
14
-
15
- default_relation = -> { unscoped }
16
- res.instance_variable_set(:@scope, proc { instance_exec(&default_relation) })
17
- end
18
- end
19
-
20
- # Check if the association class has passive columns
21
- # @param [ActiveRecord::Reflection::AssociationReflection] res
22
- def _klass_has_passive_columns(res)
23
- res.klass.respond_to?(:_passive_columns)
24
- rescue NameError
25
- # If +config.eager_load!+ is disabled, an association class may not be loaded yet
26
- # so we can't constantize to check if the class has passive columns.
27
- # In this case, we assume the class has passive columns.
28
- true
29
- end
30
- end
31
- end
32
- end