rhino_project_core 0.21.0.beta.39 → 0.21.0.beta.45
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2067ef29a2dafd97f80be50db1bd8d96de7826914480ffe7b2455afb3a2c3846
|
4
|
+
data.tar.gz: 9847bf820bd6b94b0affb6fc0a98778fad403de9b431ab0dc7fa0c4812232a69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5eceb42ab45721610b6d13f0fe81b8c49db1272b5b5b1f9ff61dfa0aec10980c598832222cd06af2bad04fd693ca34de7acccd6091e205c750bc94569b9d53e6
|
7
|
+
data.tar.gz: 807591098866d30ea4843849292f5efe54ac4e44e486775039403eb4a1f4e3a58fa80eed31f6e0c61e2a42334b030b45c882f1c7cc0a5a69a85599a9c151a2ad
|
@@ -26,7 +26,7 @@ module Rhino
|
|
26
26
|
g.vertex_iterator { |c| Rhino.resource_classes.each(&c) }
|
27
27
|
|
28
28
|
# If its owned by another resoource, link it
|
29
|
-
g.adjacent_iterator { |v, c| c.call(v.
|
29
|
+
g.adjacent_iterator { |v, c| c.call(v.owner_class) if v&.resource_owned_by && !v.global_owner? }
|
30
30
|
|
31
31
|
g.directed = true
|
32
32
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rhino
|
4
|
+
module Resource
|
5
|
+
module ActiveRecordExtension
|
6
|
+
module Owner
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
# The self is actually required to work with class_attribute properly
|
10
|
+
class_methods do
|
11
|
+
def owner_class
|
12
|
+
reflect_on_association(resource_owned_by).klass
|
13
|
+
end
|
14
|
+
|
15
|
+
# Test if rhino_owner[rdoc-ref:rhino_owner] is the global owner
|
16
|
+
# Also available on the instance
|
17
|
+
def global_owned?
|
18
|
+
chained_scope = self
|
19
|
+
while !chained_scope.auth_owner? && !chained_scope.base_owner? && !chained_scope.global_owner?
|
20
|
+
chained_scope = chained_scope.owner_class
|
21
|
+
end
|
22
|
+
|
23
|
+
chained_scope.global_owner?
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def simple_joins_for(parent)
|
28
|
+
# FIXME: There is probably a more rubyish way to do this
|
29
|
+
chained_scope = self
|
30
|
+
joins = []
|
31
|
+
|
32
|
+
# The ownership could be a many, so we classify first
|
33
|
+
while chained_scope.owner_class.name != parent.to_s.classify
|
34
|
+
joins << chained_scope.resource_owned_by
|
35
|
+
chained_scope = chained_scope.owner_class
|
36
|
+
end
|
37
|
+
joins << chained_scope.resource_owned_by
|
38
|
+
|
39
|
+
joins.reverse
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -5,6 +5,7 @@ require_relative 'active_record_extension/properties'
|
|
5
5
|
require_relative 'active_record_extension/reference'
|
6
6
|
require_relative 'active_record_extension/describe'
|
7
7
|
require_relative 'active_record_extension/routing'
|
8
|
+
require_relative 'active_record_extension/owner'
|
8
9
|
require_relative 'active_record_extension/params'
|
9
10
|
require_relative 'active_record_extension/serialization'
|
10
11
|
require_relative 'active_record_extension/search'
|
data/lib/rhino/resource/owner.rb
CHANGED
@@ -35,13 +35,13 @@ module Rhino
|
|
35
35
|
self == Rhino.base_owner
|
36
36
|
end
|
37
37
|
|
38
|
-
# Test if rhino_owner[rdoc-ref:rhino_owner] is the
|
38
|
+
# Test if rhino_owner[rdoc-ref:rhino_owner] is the global owner
|
39
39
|
# Also available on the instance
|
40
40
|
def global_owner?
|
41
41
|
self.resource_owned_by == :global
|
42
42
|
end
|
43
43
|
|
44
|
-
# Test if rhino_owner[rdoc-ref:rhino_owner] is the
|
44
|
+
# Test if rhino_owner[rdoc-ref:rhino_owner] is globally owned at the top of the hierarchy
|
45
45
|
# Also available on the instance
|
46
46
|
def global_owned?
|
47
47
|
chained_scope = self
|
@@ -133,40 +133,40 @@ module Rhino
|
|
133
133
|
end
|
134
134
|
|
135
135
|
private
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
136
|
+
def simple_joins_for(parent)
|
137
|
+
# FIXME: There is probably a more rubyish way to do this
|
138
|
+
chained_scope = self
|
139
|
+
joins = []
|
140
|
+
|
141
|
+
# The ownership could be a many, so we classify first
|
142
|
+
while chained_scope.resource_owned_by.to_s.classify != parent.to_s.classify
|
143
|
+
joins << chained_scope.resource_owned_by
|
144
|
+
chained_scope = chained_scope.resource_owned_by.to_s.classify.constantize
|
145
|
+
end
|
143
146
|
joins << chained_scope.resource_owned_by
|
144
|
-
chained_scope = chained_scope.resource_owned_by.to_s.classify.constantize
|
145
|
-
end
|
146
|
-
joins << chained_scope.resource_owned_by
|
147
147
|
|
148
|
-
|
149
|
-
|
148
|
+
joins.reverse
|
149
|
+
end
|
150
150
|
|
151
|
-
|
152
|
-
|
153
|
-
|
151
|
+
def simple_joins_for_base_owner
|
152
|
+
simple_joins_for(Rhino.base_owner)
|
153
|
+
end
|
154
154
|
end
|
155
155
|
# rubocop:enable Style/RedundantSelf
|
156
156
|
end
|
157
157
|
|
158
158
|
private
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
159
|
+
# We use the parent as the starting point because if the record is not
|
160
|
+
# persisted yet, we won't be able to find it
|
161
|
+
def owner_ids(joins)
|
162
|
+
bo = Rhino.base_owner
|
163
163
|
|
164
|
-
|
164
|
+
return [] unless owner
|
165
165
|
|
166
|
-
|
167
|
-
|
166
|
+
parent_klass = owner.class
|
167
|
+
pk = parent_klass.primary_key
|
168
168
|
|
169
|
-
|
170
|
-
|
169
|
+
parent_klass.joins(parent_klass.send(joins)).where("#{pk}": owner[pk]).pluck("#{bo.table_name}.#{bo.primary_key}")
|
170
|
+
end
|
171
171
|
end
|
172
172
|
end
|
data/lib/rhino/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhino_project_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.21.0.beta.
|
4
|
+
version: 0.21.0.beta.45
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Rosevear
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -465,6 +465,7 @@ files:
|
|
465
465
|
- lib/rhino/resource/active_model_extension/serialization.rb
|
466
466
|
- lib/rhino/resource/active_record_extension.rb
|
467
467
|
- lib/rhino/resource/active_record_extension/describe.rb
|
468
|
+
- lib/rhino/resource/active_record_extension/owner.rb
|
468
469
|
- lib/rhino/resource/active_record_extension/params.rb
|
469
470
|
- lib/rhino/resource/active_record_extension/properties.rb
|
470
471
|
- lib/rhino/resource/active_record_extension/properties_describe.rb
|
@@ -508,7 +509,7 @@ homepage: ''
|
|
508
509
|
licenses:
|
509
510
|
- MIT
|
510
511
|
metadata: {}
|
511
|
-
post_install_message:
|
512
|
+
post_install_message:
|
512
513
|
rdoc_options: []
|
513
514
|
require_paths:
|
514
515
|
- lib
|
@@ -524,7 +525,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
524
525
|
version: '0'
|
525
526
|
requirements: []
|
526
527
|
rubygems_version: 3.5.16
|
527
|
-
signing_key:
|
528
|
+
signing_key:
|
528
529
|
specification_version: 4
|
529
530
|
summary: ''
|
530
531
|
test_files: []
|