Method: JSON::Schema#initialize
- Defined in:
- lib/json-schema/schema.rb
#initialize(schema, uri, parent_validator = nil) ⇒ Schema
Returns a new instance of Schema.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/json-schema/schema.rb', line 8 def initialize(schema,uri,parent_validator=nil) @schema = schema @uri = uri # If there is an ID on this schema, use it to generate the URI if @schema['id'] && @schema['id'].kind_of?(String) temp_uri = JSON::Util::URI.parse(@schema['id']) if temp_uri.relative? temp_uri = uri.join(temp_uri) end @uri = temp_uri end @uri = JSON::Util::URI.strip_fragment(@uri) # If there is a $schema on this schema, use it to determine which validator to use if @schema['$schema'] @validator = JSON::Validator.validator_for_uri(@schema['$schema']) elsif parent_validator @validator = parent_validator else @validator = JSON::Validator.default_validator end end |