Class: Jschematic::Context
- Inherits:
-
Object
- Object
- Jschematic::Context
- Defined in:
- lib/jschematic/context.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_schema(id, schema) ⇒ Object
-
#initialize(*raw_schemas) ⇒ Context
constructor
A new instance of Context.
- #schema_for(ref) ⇒ Object
- #validate!(instance, raw_schema) ⇒ Object
Constructor Details
Class Method Details
.add_schema(id, schema) ⇒ Object
16 17 18 |
# File 'lib/jschematic/context.rb', line 16 def self.add_schema(id, schema) schemas[id] = schema end |
.empty ⇒ Object
24 25 26 |
# File 'lib/jschematic/context.rb', line 24 def self.empty new end |
.schema_for(ref) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/jschematic/context.rb', line 5 def self.schema_for(ref) if ref.relative? rel = ref.omit(:scheme, :host, :port) if match = schemas.find{ |ref, _| rel == ref.omit(:scheme, :host, :port) } match[-1] end else schemas[ref] end end |
.schemas ⇒ Object
20 21 22 |
# File 'lib/jschematic/context.rb', line 20 def self.schemas @schemas ||= {} end |
Instance Method Details
#add_schema(id, schema) ⇒ Object
36 37 38 |
# File 'lib/jschematic/context.rb', line 36 def add_schema(id, schema) self.class.add_schema(id, schema) end |
#schema_for(ref) ⇒ Object
40 41 42 |
# File 'lib/jschematic/context.rb', line 40 def schema_for(ref) self.class.schema_for(ref) end |