bp3-core 0.7.0 → 0.7.1
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/bp3/core/rqid.rb +4 -0
- data/lib/bp3/core/tenantable.rb +10 -5
- data/lib/bp3/core/version.rb +1 -1
- data/lib/bp3/core.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f2e93524b2bf6c2eda309faaa77777bf7b1c1c199564caf634a2b8253e96748f
|
|
4
|
+
data.tar.gz: b8939fabb44fa8b631bbc69074014b06242d55491b5b7b211330d3ecfb17b7e0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f898ac5bb535ca59d516fb37378450aa68d007abe0e504300dce13214d08ade4342666214ed9e1c35bf5772c30b6bfb465aed30440107b2945f34848b0259785
|
|
7
|
+
data.tar.gz: 7169d6b4e47aeea757d911eacaf22fd84ad1bab6a4b1920fa33e63b4dc47c527825aac3a94388f39e4430b7e8833e771789b0d9574e958907d3149de295e2767
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/bp3/core/rqid.rb
CHANGED
|
@@ -7,6 +7,10 @@ module Bp3
|
|
|
7
7
|
|
|
8
8
|
mattr_accessor :global_request_state_class_name, :global_request_state_method
|
|
9
9
|
|
|
10
|
+
# The records of the request a row was written in, found through the rqid they share. Sharing a
|
|
11
|
+
# request is not belonging to it, so Tenantable leaves them out of its site check.
|
|
12
|
+
REQUEST_ASSOCIATIONS = %i[original_request original_response original_visit].freeze
|
|
13
|
+
|
|
10
14
|
def self.global_request_state_class
|
|
11
15
|
global_request_state_class_name.constantize
|
|
12
16
|
end
|
data/lib/bp3/core/tenantable.rb
CHANGED
|
@@ -8,6 +8,10 @@ module Bp3
|
|
|
8
8
|
# The belongs_to associations with a site check of their own
|
|
9
9
|
SITE_CHECKED_ASSOCIATIONS = %i[sites_site tenant workspaces_workspace].freeze
|
|
10
10
|
|
|
11
|
+
# The belongs_to associations the check of the records a row belongs to passes over: those with
|
|
12
|
+
# a check of their own, and Rqid's, which point at the records of the request the row was written in
|
|
13
|
+
UNCHECKED_BELONGS_TO = (SITE_CHECKED_ASSOCIATIONS + Bp3::Core::Rqid::REQUEST_ASSOCIATIONS).freeze
|
|
14
|
+
|
|
11
15
|
# The application's request state, the Bp3::RequestState::Base subclass Bp3::Core::Rqid is
|
|
12
16
|
# configured with
|
|
13
17
|
def self.global_request_state
|
|
@@ -81,7 +85,7 @@ module Bp3
|
|
|
81
85
|
return if site_id.nil?
|
|
82
86
|
|
|
83
87
|
self.class.reflect_on_all_associations(:belongs_to).each do |reflection|
|
|
84
|
-
next if
|
|
88
|
+
next if UNCHECKED_BELONGS_TO.include?(reflection.name) || !belonged_record_changed?(reflection)
|
|
85
89
|
|
|
86
90
|
belonged_site_id = belonged_record_site_id(reflection)
|
|
87
91
|
next if belonged_site_id.nil? || belonged_site_id == site_id
|
|
@@ -96,7 +100,8 @@ module Bp3
|
|
|
96
100
|
association(reflection.name).target&.new_record?
|
|
97
101
|
end
|
|
98
102
|
|
|
99
|
-
# The site of the record the association points to, nil when that record has no site
|
|
103
|
+
# The site of the record the association points to, nil when that record has no site. Looked up
|
|
104
|
+
# by the column the foreign key holds, which is the association's primary_key: when one is given.
|
|
100
105
|
def belonged_record_site_id(reflection)
|
|
101
106
|
loaded = association(reflection.name)
|
|
102
107
|
if loaded.loaded? && !loaded.stale_target? && loaded.target
|
|
@@ -104,10 +109,10 @@ module Bp3
|
|
|
104
109
|
end
|
|
105
110
|
|
|
106
111
|
klass = belonged_record_class(reflection)
|
|
107
|
-
|
|
108
|
-
return if klass.nil? ||
|
|
112
|
+
key = self[reflection.foreign_key]
|
|
113
|
+
return if klass.nil? || key.nil? || !klass.column_names.include?('sites_site_id')
|
|
109
114
|
|
|
110
|
-
klass.unscoped.where(klass
|
|
115
|
+
klass.unscoped.where(reflection.association_primary_key(klass) => key).pick(:sites_site_id)
|
|
111
116
|
end
|
|
112
117
|
|
|
113
118
|
def belonged_record_class(reflection)
|
data/lib/bp3/core/version.rb
CHANGED
data/lib/bp3/core.rb
CHANGED
|
@@ -10,8 +10,8 @@ require_relative 'core/feature_flags'
|
|
|
10
10
|
require_relative 'core/ransackable'
|
|
11
11
|
require_relative 'core/settings'
|
|
12
12
|
require_relative 'core/system_logs'
|
|
13
|
-
require_relative 'core/tenantable'
|
|
14
13
|
require_relative 'core/rqid'
|
|
14
|
+
require_relative 'core/tenantable'
|
|
15
15
|
require_relative 'core/sqnr'
|
|
16
16
|
require_relative 'core/version'
|
|
17
17
|
|