linked_rails 0.0.4.pre.g0ec6e30ca → 0.0.4.pre.g1faca9643
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/linked_rails/bulk_controller.rb +0 -2
- data/app/models/linked_rails/actions/item.rb +6 -14
- data/app/models/linked_rails/actions/object.rb +3 -5
- data/app/models/linked_rails/collection/view.rb +8 -9
- data/app/models/linked_rails/form/field/file_input.rb +1 -5
- data/app/models/linked_rails/form/field_factory.rb +7 -1
- data/app/models/linked_rails/manifest.rb +1 -1
- data/app/models/linked_rails/menus/item.rb +1 -1
- data/app/models/linked_rails/menus/list.rb +3 -14
- data/app/policies/linked_rails/collection_policy.rb +0 -1
- data/app/serializers/linked_rails/actions/object_serializer.rb +9 -0
- data/app/serializers/linked_rails/collection/view_serializer.rb +0 -1
- data/lib/linked_rails/helpers/delta_helper.rb +1 -3
- data/lib/linked_rails/helpers/resource_helper.rb +1 -4
- data/lib/linked_rails/iri_mapper.rb +1 -1
- data/lib/linked_rails/model/collections.rb +1 -3
- data/lib/linked_rails/params_parser.rb +4 -14
- data/lib/linked_rails/serializer/actionable.rb +3 -3
- data/lib/linked_rails/serializer.rb +1 -7
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bcaf6bc87f6e88d1626c597fea7cf0361c4f1a9ee572715996fdc8d03984775
|
4
|
+
data.tar.gz: 23b91ff76861c82af758a145a57da5ceb1f454d846fe2a96a3b091dd70a2f725
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a0c7d898e9c886863e8ef882fc2b95a24fb6ce59fb5a9a608556d7e374741a529bc8a672f1d69367b8845c6c77ef477c7a2093591b9e9af4fe487b5c30a5511
|
7
|
+
data.tar.gz: fe4952657dd9897c0fd430ff679f75d1d71423ec27f9f610ab2e43fb4e77fe9885873d1756989f80dd67e0d7953cfe0e3d926bd2711a87e8b7b591258456cc4e
|
@@ -61,15 +61,13 @@ module LinkedRails
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def object
|
64
|
-
|
65
|
-
end
|
64
|
+
@object = list.instance_exec(&@object) if @object.respond_to?(:call)
|
66
65
|
|
67
|
-
|
68
|
-
iri_with_root(object_root_relative_iri)
|
66
|
+
@object || resource
|
69
67
|
end
|
70
68
|
|
71
|
-
def
|
72
|
-
object&.iri&.anonymous? ?
|
69
|
+
def object_iri
|
70
|
+
object&.iri&.anonymous? ? anonymous_object_iri : object&.iri
|
73
71
|
end
|
74
72
|
|
75
73
|
def parent
|
@@ -140,8 +138,8 @@ module LinkedRails
|
|
140
138
|
|
141
139
|
private
|
142
140
|
|
143
|
-
def
|
144
|
-
object_iri =
|
141
|
+
def anonymous_object_iri
|
142
|
+
object_iri = iri.dup
|
145
143
|
object_iri.path += '/action_object'
|
146
144
|
object_iri
|
147
145
|
end
|
@@ -154,12 +152,6 @@ module LinkedRails
|
|
154
152
|
LinkedRails.translate(:action, :label, self)
|
155
153
|
end
|
156
154
|
|
157
|
-
def object_from_var
|
158
|
-
return @object unless @object.respond_to?(:call)
|
159
|
-
|
160
|
-
@object = list.instance_exec(&@object)
|
161
|
-
end
|
162
|
-
|
163
155
|
def policy_expired?
|
164
156
|
@policy_expired ||= policy && resource_policy.try(:expired?)
|
165
157
|
end
|
@@ -12,8 +12,8 @@ module LinkedRails
|
|
12
12
|
alias parent action
|
13
13
|
delegate :object, to: :action
|
14
14
|
|
15
|
-
def
|
16
|
-
action.
|
15
|
+
def iri
|
16
|
+
action.object_iri
|
17
17
|
end
|
18
18
|
|
19
19
|
class << self
|
@@ -30,9 +30,7 @@ module LinkedRails
|
|
30
30
|
|
31
31
|
parent = parent_from_params!(params, user_context)
|
32
32
|
|
33
|
-
|
34
|
-
object.instance_variable_set(:@iri, parent.object_iri)
|
35
|
-
object
|
33
|
+
new(action: parent) if parent.object.anonymous_iri?
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
@@ -8,9 +8,8 @@ module LinkedRails
|
|
8
8
|
include LinkedRails::Model
|
9
9
|
|
10
10
|
attr_accessor :collection, :filter
|
11
|
-
delegate :apply_scope, :association_base, :association_class, :
|
12
|
-
:
|
13
|
-
to: :collection
|
11
|
+
delegate :apply_scope, :association_base, :association_class, :default_page_size, :display, :include_members,
|
12
|
+
:parent, :policy, :total_page_count, :unfiltered_collection, :user_context, to: :collection
|
14
13
|
delegate :count, to: :members
|
15
14
|
|
16
15
|
alias id iri
|
@@ -43,7 +42,7 @@ module LinkedRails
|
|
43
42
|
end
|
44
43
|
|
45
44
|
def preview_includes
|
46
|
-
include_members ? {
|
45
|
+
include_members ? {member_sequence: :members} : %i[member_sequence]
|
47
46
|
end
|
48
47
|
|
49
48
|
def title
|
@@ -76,19 +75,19 @@ module LinkedRails
|
|
76
75
|
end
|
77
76
|
|
78
77
|
def iris_from_scope?
|
79
|
-
members_query.is_a?(ActiveRecord::Relation) && !polymorphic_collection?
|
78
|
+
members_query.is_a?(ActiveRecord::Relation) && !polymorphic_collection?
|
80
79
|
end
|
81
80
|
|
82
81
|
def members_array
|
83
82
|
members_query.to_a
|
84
83
|
end
|
85
84
|
|
86
|
-
def polymorphic_collection?
|
87
|
-
column =
|
88
|
-
polymorphic =
|
85
|
+
def polymorphic_collection?
|
86
|
+
column = association_class.inheritance_column
|
87
|
+
polymorphic = association_class.columns_hash.include?(column)
|
89
88
|
return false unless polymorphic
|
90
89
|
|
91
|
-
return true if
|
90
|
+
return true if association_class.descends_from_active_record?
|
92
91
|
|
93
92
|
members_query.where_values_hash.include?(column) &&
|
94
93
|
members_query.where_values_hash[column] != association_class.to_s
|
@@ -52,7 +52,13 @@ module LinkedRails
|
|
52
52
|
private
|
53
53
|
|
54
54
|
def attr_column(name)
|
55
|
-
|
55
|
+
column_model =
|
56
|
+
if model_class.is_delegated_attribute?(name)
|
57
|
+
model_class.class_for_delegated_attribute(name)
|
58
|
+
else
|
59
|
+
model_class
|
60
|
+
end
|
61
|
+
column_model.column_for_attribute(name)
|
56
62
|
end
|
57
63
|
|
58
64
|
def attr_to_datatype # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
@@ -41,7 +41,7 @@ module LinkedRails
|
|
41
41
|
def blob_preview_iri
|
42
42
|
return unless ActiveStorage::Blob.service.present?
|
43
43
|
|
44
|
-
"#{LinkedRails.iri(path: 'rails/active_storage/blobs/redirect')}/{signed_id}/preview"
|
44
|
+
"#{LinkedRails.iri(path: 'rails/active_storage/blobs/redirect')}/{signed_id}/preview')"
|
45
45
|
end
|
46
46
|
|
47
47
|
def blob_upload_iri
|
@@ -49,8 +49,9 @@ module LinkedRails
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def menu_item(tag, options) # rubocop:disable Metrics/AbcSize
|
52
|
-
|
53
|
-
|
52
|
+
if options[:policy].present?
|
53
|
+
return unless resource_policy(options[:policy_resource]).send(options[:policy], *options[:policy_arguments])
|
54
|
+
end
|
54
55
|
options[:label_params] ||= {}
|
55
56
|
options[:label_params][:default] ||= ["menus.default.#{tag}".to_sym, tag.to_s.capitalize]
|
56
57
|
options[:label] ||= default_label(tag, options)
|
@@ -59,10 +60,6 @@ module LinkedRails
|
|
59
60
|
LinkedRails.menus_item_class.new(resource: resource, tag: tag, parent: self, **options)
|
60
61
|
end
|
61
62
|
|
62
|
-
def policy_verdict(policy, options)
|
63
|
-
policy.send(options[:policy], *options[:policy_arguments])
|
64
|
-
end
|
65
|
-
|
66
63
|
def resource_policy(policy_resource)
|
67
64
|
policy_resource ||= resource
|
68
65
|
policy_resource = instance_exec(&policy_resource) if policy_resource.respond_to?(:call)
|
@@ -72,14 +69,6 @@ module LinkedRails
|
|
72
69
|
@resource_policy[policy_resource] ||= Pundit.policy(user_context, policy_resource)
|
73
70
|
end
|
74
71
|
|
75
|
-
def show_menu_item?(_tag, options)
|
76
|
-
return true if options[:policy].blank?
|
77
|
-
|
78
|
-
policy = resource_policy(options[:policy_resource])
|
79
|
-
|
80
|
-
policy_verdict(policy, options)
|
81
|
-
end
|
82
|
-
|
83
72
|
def iri_template
|
84
73
|
base_template = resource.send(resource.try(:singular_resource?) ? :singular_iri_template : :iri_template)
|
85
74
|
|
@@ -8,9 +8,7 @@ module LinkedRails
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def invalidate_collection_delta(collection)
|
11
|
-
|
12
|
-
|
13
|
-
[Vocab.sp[:Variable], Vocab.ontola[:baseCollection], iri, delta_iri(:invalidate)]
|
11
|
+
[Vocab.sp[:Variable], Vocab.ontola[:baseCollection], collection.iri, delta_iri(:invalidate)]
|
14
12
|
end
|
15
13
|
|
16
14
|
def invalidate_parent_collections_delta(resource)
|
@@ -58,10 +58,7 @@ module LinkedRails
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def new_resource_from_parent
|
61
|
-
if requested_resource.is_a?(
|
62
|
-
requested_resource.is_a?(LinkedRails.collection_view_class)
|
63
|
-
return requested_resource.child_resource
|
64
|
-
end
|
61
|
+
return requested_resource.child_resource if requested_resource.is_a?(Collection)
|
65
62
|
|
66
63
|
parent_resource.build_child(
|
67
64
|
controller_class,
|
@@ -38,7 +38,7 @@ module LinkedRails
|
|
38
38
|
params = Rails.application.routes.recognize_path(iri.to_s, method: method)
|
39
39
|
|
40
40
|
route_params_to_opts(params.merge(query), iri.to_s)
|
41
|
-
rescue ActionController::RoutingError
|
41
|
+
rescue ActionController::RoutingError
|
42
42
|
EMPTY_IRI_OPTS.dup
|
43
43
|
end
|
44
44
|
|
@@ -70,9 +70,7 @@ module LinkedRails
|
|
70
70
|
|
71
71
|
module ClassMethods
|
72
72
|
def collection_iri(**opts)
|
73
|
-
|
74
|
-
|
75
|
-
LinkedRails.iri(path: collection_root_relative_iri(**opts), fragment: fragment)
|
73
|
+
LinkedRails.iri(path: collection_root_relative_iri(**opts))
|
76
74
|
end
|
77
75
|
|
78
76
|
# Sets the defaults for all collections for this class.
|
@@ -118,13 +118,9 @@ module LinkedRails
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def parse_attribute(klass, field_options, value)
|
121
|
-
|
122
|
-
end
|
123
|
-
|
124
|
-
def parse_attribute_value(klass, field_options, value)
|
125
|
-
return nil if value == Vocab.libro[:null]
|
121
|
+
parsed_value = parse_enum_attribute(klass, field_options.key, value) || value
|
126
122
|
|
127
|
-
|
123
|
+
[field_options.key, parsed_value.to_s]
|
128
124
|
end
|
129
125
|
|
130
126
|
def parse_enum_attribute(klass, key, value)
|
@@ -137,15 +133,9 @@ module LinkedRails
|
|
137
133
|
|
138
134
|
def parse_iri_param(iri, reflection)
|
139
135
|
key = foreign_key_for_reflection(reflection)
|
140
|
-
|
136
|
+
value = parse_iri_param_value(iri, reflection) if key
|
141
137
|
|
142
|
-
|
143
|
-
[key, nil]
|
144
|
-
else
|
145
|
-
value = parse_iri_param_value(iri, reflection)
|
146
|
-
|
147
|
-
[key, value.to_s] if value
|
148
|
-
end
|
138
|
+
[key, value.to_s] if value
|
149
139
|
end
|
150
140
|
|
151
141
|
def parse_iri_param_value(iri, reflection)
|
@@ -15,10 +15,10 @@ module LinkedRails
|
|
15
15
|
|
16
16
|
module ClassMethods
|
17
17
|
def action_triples(object, _params)
|
18
|
-
if
|
19
|
-
object.try(:action_triples) || []
|
20
|
-
else
|
18
|
+
if object.iri.anonymous? && !object.try(:singular_resource?)
|
21
19
|
[]
|
20
|
+
else
|
21
|
+
object.try(:action_triples) || []
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -115,13 +115,7 @@ module LinkedRails
|
|
115
115
|
collection_name = "#{name.to_s.singularize}_collection"
|
116
116
|
opts[:association] ||= name
|
117
117
|
opts[:polymorphic] ||= true
|
118
|
-
|
119
|
-
action_object = opts.delete(:action_object)
|
120
|
-
opts[:if] ||= -> (object) {
|
121
|
-
return action_object if object.iri.try(:path)&.end_with?('/action_object')
|
122
|
-
|
123
|
-
named_object?(object)
|
124
|
-
}
|
118
|
+
opts[:if] ||= method(:named_object?)
|
125
119
|
|
126
120
|
collection_opts = {}
|
127
121
|
collection_opts[:page_size] = opts.delete(:page_size) if opts.key?(:page_size)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linked_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.4.pre.
|
4
|
+
version: 0.0.4.pre.g1faca9643
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arthur Dingemans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_response
|
@@ -305,6 +305,7 @@ files:
|
|
305
305
|
- app/policies/linked_rails/ontology_policy.rb
|
306
306
|
- app/policies/linked_rails/sequence_policy.rb
|
307
307
|
- app/serializers/linked_rails/actions/item_serializer.rb
|
308
|
+
- app/serializers/linked_rails/actions/object_serializer.rb
|
308
309
|
- app/serializers/linked_rails/collection/filter_field_serializer.rb
|
309
310
|
- app/serializers/linked_rails/collection/filter_option_serializer.rb
|
310
311
|
- app/serializers/linked_rails/collection/filter_serializer.rb
|