Class: EasyJSONMatcher::SchemaLibrary
- Inherits:
-
Object
- Object
- EasyJSONMatcher::SchemaLibrary
- Defined in:
- lib/easy_json_matcher/schema_library.rb
Class Method Summary collapse
- .add_schema(name:, schema:) ⇒ Object
- .available_schemas ⇒ Object
-
.get_schema(name:, opts: {}) ⇒ Object
TODO: error message should read “called #name, not with #name”.
- .schema_for(name) ⇒ Object
- .use_schema(name:, wrap_with: Validator) ⇒ Object
Class Method Details
.add_schema(name:, schema:) ⇒ Object
18 19 20 |
# File 'lib/easy_json_matcher/schema_library.rb', line 18 def add_schema(name:, schema:) SCHEMAS[name] = schema end |
.available_schemas ⇒ Object
10 11 12 |
# File 'lib/easy_json_matcher/schema_library.rb', line 10 def available_schemas SCHEMAS.keys end |
.get_schema(name:, opts: {}) ⇒ Object
TODO: error message should read “called #name, not with #name”
23 24 25 26 27 |
# File 'lib/easy_json_matcher/schema_library.rb', line 23 def get_schema(name:, opts: {}) -> (value:) { SCHEMAS[name]&.call(value: value) or raise UnknownValidationStepError.new(name) } end |
.schema_for(name) ⇒ Object
14 15 16 |
# File 'lib/easy_json_matcher/schema_library.rb', line 14 def schema_for(name) SCHEMAS[name] end |
.use_schema(name:, wrap_with: Validator) ⇒ Object
29 30 31 |
# File 'lib/easy_json_matcher/schema_library.rb', line 29 def use_schema(name:, wrap_with: Validator) wrap_with.new validate_with: get_schema(name: name) end |