Class: Yori::SchemaBase
- Inherits:
-
Hash
- Object
- Hash
- Yori::SchemaBase
show all
- Extended by:
- Forwardable
- Defined in:
- lib/yori/schema_base.rb
Overview
Direct Known Subclasses
Yori::Schema::Any, Yori::Schema::V3::Callback, Yori::Schema::V3::Components, Yori::Schema::V3::Contact, Yori::Schema::V3::Discriminator, Yori::Schema::V3::Encoding, Yori::Schema::V3::Example, Yori::Schema::V3::ExternalDocumentation, Yori::Schema::V3::Info, Yori::Schema::V3::License, Yori::Schema::V3::Link, Yori::Schema::V3::MediaType, Yori::Schema::V3::OAuthFlow, Yori::Schema::V3::OAuthFlows, Yori::Schema::V3::OpenAPI, Yori::Schema::V3::Operation, Yori::Schema::V3::Parameter, Yori::Schema::V3::PathItem, Yori::Schema::V3::Paths, Yori::Schema::V3::RequestBody, Yori::Schema::V3::Response, Yori::Schema::V3::Responses, Yori::Schema::V3::Schema, Yori::Schema::V3::SecurityRequirement, Yori::Schema::V3::SecurityScheme, Yori::Schema::V3::Server, Yori::Schema::V3::ServerVariable, Yori::Schema::V3::Tag, Yori::Schema::V3::XML
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
22
23
24
|
# File 'lib/yori/schema_base.rb', line 22
def id
@id
end
|
Class Method Details
.eval_class!(klass, id, &block) ⇒ Object
50
51
52
53
54
55
56
57
|
# File 'lib/yori/schema_base.rb', line 50
def eval_class!(klass, id, &block)
klass.new.tap do |c|
raise 'must inherit SchemaBase class' unless c.is_a?(SchemaBase)
c.id = id
c.instance_eval(&block)
c.validate!
end
end
|
.eval_hash!(klass, id, value) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/yori/schema_base.rb', line 42
def eval_hash!(klass, id, value)
klass[value].tap do |c|
raise 'must inherit SchemaBase class' unless c.is_a?(SchemaBase)
c.id = id
c.validate!
end
end
|
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/yori/schema_base.rb', line 29
def eval_input!(klass, id, value = nil, &block)
return eval_class!(klass, id, &block) unless value
case value
when String, FalseClass
value when Hash
eval_hash!(klass, id, value)
else
raise 'direct assignment value must be a Hash'
end
end
|
Instance Method Details
#ref(value) ⇒ Object
24
25
26
|
# File 'lib/yori/schema_base.rb', line 24
def ref(value)
self['$ref'] = value
end
|
#validate! ⇒ Object
20
|
# File 'lib/yori/schema_base.rb', line 20
def validate!; end
|
#validator ⇒ Object
16
17
18
|
# File 'lib/yori/schema_base.rb', line 16
def validator
@validator ||= Yori::SchemaValidator.new(self)
end
|