Skip to content

Commit

Permalink
JSI.new_schema / Schema.new_schema don't delegate **kw so yard can se…
Browse files Browse the repository at this point in the history
…e default values
  • Loading branch information
notEthan committed May 28, 2023
1 parent c7fdec2 commit 1f7e287
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
14 changes: 12 additions & 2 deletions lib/jsi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,18 @@ class Bug < NotImplementedError
autoload :SimpleWrap, 'jsi/simple_wrap'

# (see JSI::Schema.new_schema)
def self.new_schema(schema_content, **kw)
JSI::Schema.new_schema(schema_content, **kw)
def self.new_schema(schema_content,
# params of Schema.new_schema have their default values repeated here. delegating in a splat
# would remove repetition, but yard doesn't display delegated defaults with its (see X) directive.
default_metaschema: nil,
uri: nil,
stringify_symbol_keys: true
)
JSI::Schema.new_schema(schema_content,
default_metaschema: default_metaschema,
uri: uri,
stringify_symbol_keys: stringify_symbol_keys,
)
end

# Instantiates the given schema content as a JSI Schema, passing all params to
Expand Down
9 changes: 6 additions & 3 deletions lib/jsi/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,15 @@ def default_metaschema=(default_metaschema)
# the given `schema_content` and whose schemas are inplace applicators of the indicated metaschema
def new_schema(schema_content,
default_metaschema: nil,
stringify_symbol_keys: true,
**kw
# params of DescribesSchema#new_schema have their default values repeated here. delegating in a splat
# would remove repetition, but yard doesn't display delegated defaults with its (see X) directive.
uri: nil,
stringify_symbol_keys: true
)
new_schema_params = {
uri: uri,
stringify_symbol_keys: stringify_symbol_keys,
}.merge(kw)
}
default_metaschema_new_schema = -> {
default_metaschema ||= JSI::Schema.default_metaschema
if default_metaschema.nil?
Expand Down

0 comments on commit 1f7e287

Please sign in to comment.