Class: SchemaList
- Inherits:
-
Object
- Object
- SchemaList
- Defined in:
- lib/tiki/schema.rb
Instance Method Summary collapse
-
#initialize(*types) ⇒ SchemaList
constructor
A new instance of SchemaList.
- #ref(ref) ⇒ Object
- #schema(type: :object, ref: nil, **named, &block) ⇒ Object
- #to_spec ⇒ Object
Constructor Details
#initialize(*types) ⇒ SchemaList
Returns a new instance of SchemaList.
257 258 259 |
# File 'lib/tiki/schema.rb', line 257 def initialize(*types) @schemas = types.map { |type| Schema.new(type) } end |
Instance Method Details
#ref(ref) ⇒ Object
271 272 273 |
# File 'lib/tiki/schema.rb', line 271 def ref(ref) schema(ref: ref) end |
#schema(type: :object, ref: nil, **named, &block) ⇒ Object
261 262 263 264 265 266 267 268 269 |
# File 'lib/tiki/schema.rb', line 261 def schema(type: :object, ref: nil, **named, &block) if ref @schemas << Reference.new(ref) else schema = Schema.new type, **named schema.instance_eval(&block) if block @schemas << schema end end |
#to_spec ⇒ Object
275 276 277 |
# File 'lib/tiki/schema.rb', line 275 def to_spec @schemas.map(&:to_spec) end |