linked_rails 0.0.4.pre.g9b7bc9073 → 0.0.4.pre.g83aa52ab3

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: d86a69fbe49260dc07acefa64442a1a3a886a9d1b45cab169fc4e514ffe27b75
4
- data.tar.gz: 2bd8aa4736a567bbb045889c96b3c5f8c02bcfbab7bbd90b8374c86d614599d0
3
+ metadata.gz: bc8a8c53b8422c4f81be3dbb64c8488b6d80a659b0fb585f252c6d66842f240c
4
+ data.tar.gz: 83172f0d901f0ad055186902ea9f9b5e9500b16bfa2071cad5533127765b57ec
5
5
  SHA512:
6
- metadata.gz: e907be3993d7b5a334649d29f5b8703a0a3bccb5ca0c8a747b96c93e8a1e27fe30c5ae110f3cab02c80ae75e69fc5e59a33abeee0a22e6e87e030fa7d03a6410
7
- data.tar.gz: ec7768a12f8801cccf9e2ff3b95ce295bd5257cc4d888ab010a436ec74469ec53b9f910043ef094b10239d4c2672310b4e45b08aff57a44f1a4f30af6fb5004a
6
+ metadata.gz: 0c00be6915256007188a56ed84b1b485dd5c56fcf6e310ab525d66488f26498b0127abb4bf39f6e6b206192d0eed9410b891ba21407794653349bbcde95fc95b
7
+ data.tar.gz: d1488f86b20714eb98e4cbfdf9c8a6765e84be907dae2573274c02adc22047f0a6c206dc10ce2086823ab42028517d7f440e65b121aee53e35ba84b1e57f72b6
@@ -5,20 +5,8 @@ module LinkedRails
5
5
  module Delta
6
6
  include LinkedRails::Helpers::DeltaHelper
7
7
 
8
- def changes_triples(resource) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
8
+ def changes_triples(resource)
9
9
  resource_serializer(resource)&.send(:repository).statements
10
-
11
- # resource.previous_changes_by_predicate.map do |predicate, (_old_value, _new_value)|
12
- # serializer_attributes = resource.class.predicate_mapping[predicate]
13
- # next if serializer_attributes.is_a?(FastJsonapi::Relationship)
14
- #
15
- # attr_name = serializer_attributes.key
16
- # serialized_value =
17
- # serializer.class.attributes_to_serialize[attr_name]&.serialize(resource, serializer_params, {})
18
- # (serialized_value.is_a?(Array) ? serialized_value : [serialized_value]).map do |value|
19
- # change_triple(resource, predicate, value)
20
- # end
21
- # end.compact.flatten
22
10
  end
23
11
 
24
12
  def changed_relations_triples(resource, inverted = nil) # rubocop:disable Metrics/AbcSize
@@ -35,14 +23,6 @@ module LinkedRails
35
23
 
36
24
  private
37
25
 
38
- def change_triple(resource, predicate, value)
39
- if value.nil?
40
- RDF::Statement.new(resource.iri, predicate, Vocab.sp[:Variable], graph_name: delta_iri(:remove))
41
- else
42
- RDF::Statement.new(resource.iri, predicate, value, graph_name: delta_iri(:replace))
43
- end
44
- end
45
-
46
26
  def changed_relation_triples(predicate, destructed, resources, inverted)
47
27
  related_resource_invalidations =
48
28
  resources.flat_map do |resource|
@@ -6,7 +6,7 @@ module LinkedRails
6
6
  module Middleware
7
7
  class LinkedDataParams
8
8
  include ::Empathy::EmpJson::Helpers::Slices
9
- include ::Empathy::EmpJson::Helpers::Primitives
9
+ include ::Empathy::EmpJson::Helpers::Parsing
10
10
 
11
11
  def initialize(app)
12
12
  @app = app
@@ -22,17 +22,6 @@ module LinkedRails
22
22
  end
23
23
  end
24
24
 
25
- def previous_changes_by_predicate
26
- serializer_class = RDF::Serializers.serializer_for(self)
27
- return {} unless respond_to?(:previous_changes) && serializer_class
28
-
29
- Hash[
30
- previous_changes
31
- .map { |k, v| [self.class.predicate_for_key(k.to_sym), v] }
32
- .select { |k, _v| k.present? }
33
- ]
34
- end
35
-
36
25
  def previously_changed_relations(inverted = nil)
37
26
  serializer_class = RDF::Serializers.serializer_for(self)
38
27
  return {} unless serializer_class.try(:relationships_to_serialize)
@@ -3,8 +3,7 @@
3
3
  module LinkedRails
4
4
  class ParamsParser # rubocop:disable Metrics/ClassLength
5
5
  include ::Empathy::EmpJson::Helpers::Slices
6
- include ::Empathy::EmpJson::Helpers::Primitives
7
- include ::Empathy::EmpJson::Helpers::Values
6
+ include ::Empathy::EmpJson::Helpers::Parsing
8
7
 
9
8
  attr_accessor :params, :slice, :user_context
10
9
  delegate :filter_params, to: :collection_params_parser
@@ -63,11 +62,11 @@ module LinkedRails
63
62
  def associated_class_from_params(reflection, object)
64
63
  return reflection.klass unless reflection.polymorphic?
65
64
 
66
- query = slice.query(subject: object, predicate: Vocab.rdfv[:type])
65
+ type = values_from_slice(slice, object, Vocab.rdfv[:type])
67
66
 
68
- raise("No type given for '#{object}' referenced by polymorphic association '#{reflection.name}'") if query.empty?
67
+ raise("No type given for '#{object}' referenced by polymorphic association '#{reflection.name}'") if type.blank?
69
68
 
70
- iri_to_class(query.first.object)
69
+ iri_to_class(type)
71
70
  end
72
71
 
73
72
  def collection_params_parser
@@ -78,11 +77,11 @@ module LinkedRails
78
77
  options = serializer_field(klass, predicate)
79
78
  return unless value.count == 1 && options.present?
80
79
 
81
- parsed_value = value.first.start_with?('http') ? RDF::URI(value.first) : RDF::Literal(value.first)
80
+ parsed_value = value.first.start_with?('http') ? RDF::URI(value.first) : value.first
82
81
  parse_param(
83
82
  klass,
84
83
  options.predicate,
85
- parsed_value
84
+ object_to_value(parsed_value)
86
85
  )
87
86
  end
88
87
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linked_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.pre.g9b7bc9073
4
+ version: 0.0.4.pre.g83aa52ab3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arthur Dingemans
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: kaminari-activerecord
43
43
  requirement: !ruby/object:Gem::Requirement