Skip to content

Commit

Permalink
SchemaAncestorNode#jsi_schema_resource_ancestors always set; simplify…
Browse files Browse the repository at this point in the history
… attr_reader
  • Loading branch information
notEthan committed Jul 21, 2023
1 parent a85467d commit 726d656
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/jsi/metaschema_node/bootstrap_schema.rb
Expand Up @@ -47,6 +47,7 @@ def initialize(
self.jsi_ptr = jsi_ptr
self.jsi_document = jsi_document
self.jsi_schema_base_uri = jsi_schema_base_uri
self.jsi_schema_resource_ancestors = Util::EMPTY_ARY
end

# document containing the schema content
Expand Down
11 changes: 2 additions & 9 deletions lib/jsi/schema/schema_ancestor_node.rb
Expand Up @@ -26,10 +26,7 @@ def initialize(*, **)
# resources which are ancestors of this JSI in the document. this does not include self.
# @api private
# @return [Array<JSI::Schema>]
def jsi_schema_resource_ancestors
return @jsi_schema_resource_ancestors if instance_variable_defined?(:@jsi_schema_resource_ancestors)
Util::EMPTY_ARY
end
attr_reader :jsi_schema_resource_ancestors

# the URI of the resource containing this node.
# this is always an absolute URI (with no fragment).
Expand Down Expand Up @@ -80,7 +77,6 @@ def jsi_schema_base_uri=(jsi_schema_base_uri)
end

def jsi_schema_resource_ancestors=(jsi_schema_resource_ancestors)
if jsi_schema_resource_ancestors
unless jsi_schema_resource_ancestors.respond_to?(:to_ary)
raise(TypeError, "jsi_schema_resource_ancestors must be an array; got: #{jsi_schema_resource_ancestors.inspect}")
end
Expand All @@ -103,10 +99,7 @@ def jsi_schema_resource_ancestors=(jsi_schema_resource_ancestors)
last_anc_ptr = anc.jsi_ptr
end

@jsi_schema_resource_ancestors = jsi_schema_resource_ancestors.to_ary.freeze
else
@jsi_schema_resource_ancestors = Util::EMPTY_ARY
end
@jsi_schema_resource_ancestors = jsi_schema_resource_ancestors
end

def jsi_anchor_subschemas_map
Expand Down

0 comments on commit 726d656

Please sign in to comment.