Module: SHACL::Algebra

Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra/or.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra/and.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra/not.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra/xone.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra/shape.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra/pattern.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra/operator.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra/node_shape.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra/property_shape.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra/qualified_value.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra/sparql_constraint.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra/constraint_component.rb

Overview

Based on the SPARQL Algebra, operators for executing a patch

Defined Under Namespace

Classes: AndConstraintComponent, ConstraintComponent, NodeShape, NotConstraintComponent, Operator, OrConstraintComponent, PatternConstraintComponent, PropertyShape, QualifiedValueConstraintComponent, SPARQLConstraintComponent, Shape, XoneConstraintComponent

Class Method Summary collapse

Class Method Details

.from_json(operator, **options) ⇒ Object

Raises:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/algebra.rb', line 22

def self.from_json(operator, **options)
  raise SHACL::Error, "from_json: operator not a Hash: #{operator.inspect}" unless operator.is_a?(Hash)

  # If operator is a hash containing @list, it is a single array value.
  # Note: context does not use @container: @list on this terms to preserve cardinality expectations
  return operator['@list'].map {|e| from_json(e, **options)} if operator.key?('@list')

  type = operator.fetch('type', [])
  if type.empty?
    type << if operator["path"]
      'PropertyShape'
    elsif operator['nodeValidator'] || operator['propertyValidator'] || operator['validator']
      'ConstraintComponent'
    else
      'NodeShape'
    end
  end
  klass = case
  when type.include?('NodeShape') then NodeShape
  when type.include?('PropertyShape') then PropertyShape
  when type.include?('ConstraintComponent') then ConstraintComponent
  else raise SHACL::Error, "from_json: unknown type #{type.inspect}"
  end

  klass.from_json(operator, **options)
end