Class: MediaType

Inherits:
Object
  • Object
show all
Defined in:
lib/tiki/media-type.rb

Instance Method Summary collapse

Constructor Details

#initialize(schema: :object, ref: nil) ⇒ MediaType

Returns a new instance of MediaType.



10
11
12
13
14
15
16
# File 'lib/tiki/media-type.rb', line 10

def initialize(schema: :object, ref: nil)
  if ref
    @schema = Reference.new ref
  elsif schema
    @schema = Schema.new schema
  end
end

Instance Method Details

#schema(type = :object, title = nil, ref: nil, &block) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/tiki/media-type.rb', line 18

def schema(type = :object, title = nil, ref: nil, &block)
  if ref
    @schema = Reference.new ref
  else
    @schema = Schema.new type, title
    @schema.instance_eval(&block) if block
  end
end

#to_specObject



27
28
29
30
31
# File 'lib/tiki/media-type.rb', line 27

def to_spec
  props = {}
  props[:schema] = @schema.to_spec if @schema
  props
end