Class: ApiSketch::DSL::Headers

Inherits:
Base
  • Object
show all
Defined in:
lib/api_sketch/dsl/headers.rb

Instance Method Summary collapse

Methods inherited from Base

#use_shared_block

Constructor Details

#initialize(&block) ⇒ Headers

Returns a new instance of Headers.



3
4
5
6
7
# File 'lib/api_sketch/dsl/headers.rb', line 3

def initialize(&block)
  @list = []
  define_singleton_method(:initialize_headers_list, block)
  initialize_headers_list
end

Instance Method Details

#add(name, &block) ⇒ Object



13
14
15
# File 'lib/api_sketch/dsl/headers.rb', line 13

def add(name, &block)
  @list << ::ApiSketch::Model::Header.new(::ApiSketch::DSL::AttributeParser.new(:document, &block).to_h.merge(name: name))
end

#to_aObject



9
10
11
# File 'lib/api_sketch/dsl/headers.rb', line 9

def to_a
  @list
end