Class: Jsapi::Meta::Schema::Wrapper
- Inherits:
-
Model::Wrapper
- Object
- SimpleDelegator
- Model::Wrapper
- Jsapi::Meta::Schema::Wrapper
- Defined in:
- lib/jsapi/meta/schema/wrapper.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#existence ⇒ Object
readonly
The level of existence.
Attributes inherited from Model::Wrapper
Instance Method Summary collapse
-
#default_value(context: nil) ⇒ Object
Returns the default value within
context. -
#initialize(schema, definitions) ⇒ Wrapper
constructor
A new instance of Wrapper.
Methods inherited from Model::Wrapper
Constructor Details
#initialize(schema, definitions) ⇒ Wrapper
Returns a new instance of Wrapper.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jsapi/meta/schema/wrapper.rb', line 10 def initialize(schema, definitions) @existence = [schema.existence].tap do |levels| s = schema while s.is_a?(Reference) s = s.resolve(definitions, deep: false) levels << s.existence end end.compact.max || Existence::ALLOW_OMITTED super end |
Instance Attribute Details
#existence ⇒ Object (readonly)
The level of existence.
8 9 10 |
# File 'lib/jsapi/meta/schema/wrapper.rb', line 8 def existence @existence end |
Instance Method Details
#default_value(context: nil) ⇒ Object
Returns the default value within context.
23 24 25 26 27 |
# File 'lib/jsapi/meta/schema/wrapper.rb', line 23 def default_value(context: nil) return default unless default.nil? definitions.default_value(type, context: context) end |