Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes dynamic and lexical schemas to be stored internally by the URI as a string #189

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kjeldahl
Copy link

@kjeldahl kjeldahl commented Jul 1, 2024

Fixes #188

end

def register(type, namespace_uri, schema)
@resources[type][namespace_uri.to_s] = schema
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@resources[type][namespace_uri.to_s] = schema
fail "Schema already registered as #{type} under #{namespace_uri}" if @resources[type][namespace_uri.to_s]
@resources[type][namespace_uri.to_s] = schema

Check whether the URI is already used for possibly another schema. It makes a couple of tests fail though.

Copy link
Owner

@davishmcclurg davishmcclurg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay—thanks for opening this!

@resources[type][namespace_uri.to_s] = schema
end

def lexical!(namespace_uri)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just call these uri—I don't know if "namespace" is the right terminology here.

@@ -328,7 +327,7 @@ def defs_keyword
end

def resources
@resources ||= { :lexical => {}, :dynamic => {} }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of wrapping both of these in a single object, we should pull them into separate objects. Something like:

def resources
  @resources ||= { :lexical => Resources.new, :dynamic => Resources.new }
end

Or even separate lexical_resources and dynamic_resources methods.

And then on Resources you just have to define the Hash methods that we're using (#[], #[]=, #fetch, and #key?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Schemas with URI::File references gets overwritten when storing in resources[:lexical|:dynamic]
2 participants