Class: ApiDoc::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/apidoc.rb

Defined Under Namespace

Classes: Blueprint

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Runner

Returns a new instance of Runner.



20
21
22
23
24
25
26
27
28
29
# File 'lib/apidoc.rb', line 20

def initialize(&block)
  @resources          = []
  @accept             = nil
  @content_type       = nil
  @before_each_blocks = []
  @before_all_blocks  = []
  @after_each_blocks  = []
  @after_all_blocks   = []
  Blueprint.new self, &block
end

Instance Attribute Details

#acceptObject

Returns the value of attribute accept.



31
32
33
# File 'lib/apidoc.rb', line 31

def accept
  @accept
end

#after_all_blocksObject

Returns the value of attribute after_all_blocks.



31
32
33
# File 'lib/apidoc.rb', line 31

def after_all_blocks
  @after_all_blocks
end

#after_each_blocksObject

Returns the value of attribute after_each_blocks.



31
32
33
# File 'lib/apidoc.rb', line 31

def after_each_blocks
  @after_each_blocks
end

#before_all_blocksObject

Returns the value of attribute before_all_blocks.



31
32
33
# File 'lib/apidoc.rb', line 31

def before_all_blocks
  @before_all_blocks
end

#before_each_blocksObject

Returns the value of attribute before_each_blocks.



31
32
33
# File 'lib/apidoc.rb', line 31

def before_each_blocks
  @before_each_blocks
end

#content_typeObject

Returns the value of attribute content_type.



31
32
33
# File 'lib/apidoc.rb', line 31

def content_type
  @content_type
end

#resourcesObject

Returns the value of attribute resources.



31
32
33
# File 'lib/apidoc.rb', line 31

def resources
  @resources
end

Instance Method Details

#runObject



86
87
88
89
90
91
92
93
94
# File 'lib/apidoc.rb', line 86

def run
  @before_all_blocks.each {|block| instance_eval &block }
  @resources.each do |resource|
    @before_each_blocks.each {|block| instance_eval &block }
    resource.run
    @after_each_blocks.each {|block| instance_eval &block }
  end
  @after_all_blocks.each {|block| instance_eval &block }
end