Sha256: 89a870832c71afc2d3ac647e230bc74d0e5be7b0c912ad8fc13bea83cfb84c39

Contents?: true

Size: 743 Bytes

Versions: 12

Compression:

Stored size: 743 Bytes

Contents

module ShEx::Algebra
  ##
  class External < Operator
    include ShapeExpression
    NAME = :external

    #
    # S is a ShapeRef and the Schema's shapes maps reference to a shape expression se2 and satisfies(n, se2, G, m).
    def satisfies?(focus, depth: 0)
      extern_shape = nil

      # Find the id for this external
      not_satisfied("Can't find id for this extern", depth: depth) unless id

      schema.external_schemas.each do |schema|
        extern_shape ||= schema.shapes.detect {|s| s.id == id}
      end

      not_satisfied("External not configured for this shape", depth: depth) unless extern_shape
      extern_shape.satisfies?(focus, depth: depth + 1)
    end

    def json_type
      "ShapeExternal"
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
shex-0.8.0 lib/shex/algebra/external.rb
shex-0.7.1 lib/shex/algebra/external.rb
shex-0.7.0 lib/shex/algebra/external.rb
shex-0.6.4 lib/shex/algebra/external.rb
shex-0.6.3 lib/shex/algebra/external.rb
shex-0.6.2 lib/shex/algebra/external.rb
shex-0.6.1 lib/shex/algebra/external.rb
shex-0.6.0 lib/shex/algebra/external.rb
shex-0.5.2 lib/shex/algebra/external.rb
shex-0.5.1 lib/shex/algebra/external.rb
shex-0.5.0 lib/shex/algebra/external.rb
shex-0.4.0 lib/shex/algebra/external.rb