Class: Apipony::Documentation

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

Overview

Top-level class for the DSL

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.base_urlObject

Returns the value of attribute base_url.



5
6
7
# File 'lib/apipony/documentation.rb', line 5

def base_url
  @base_url
end

.sectionsObject

Returns the value of attribute sections.



5
6
7
# File 'lib/apipony/documentation.rb', line 5

def sections
  @sections
end

.titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/apipony/documentation.rb', line 5

def title
  @title
end

Class Method Details

.config(&block) ⇒ Object

Configure API pony with the DSL



41
42
43
# File 'lib/apipony/documentation.rb', line 41

def config(&block)
  instance_eval(&block)
end

.define(&block) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/apipony/documentation.rb', line 7

def define(&block)
  @sections = []
  @title = 'API Documentation'
  @base_url = ''

  instance_eval(&block)
end

.section(title, &block) ⇒ Object

Start a new section. Sections are logically separated on the display page.



25
26
27
# File 'lib/apipony/documentation.rb', line 25

def section(title, &block)
  @sections << Apipony::Section.new(title, &block)
end

.subtype(name, **params, &block) ⇒ Object

Define a new subtype. A subtype describes a common object used in various places in your Api. Once defined, setting the ‘type` of an attribute to this given name will cause it to reference this subtype in a common location.

Parameters:

  • name (String)

    what to call this subtype



35
36
37
# File 'lib/apipony/documentation.rb', line 35

def subtype(name, **params, &block)
  Apipony.define_attribute_type(name, **params, &block)
end

.subtypesHash<String, ApiPony::ResponseAttribute] a hash of each subype. keys are the names of the subtype, values are the attribute object that defines it

Returns Hash<String, ApiPony::ResponseAttribute] a hash of each subype. keys are the names of the subtype, values are the attribute object that defines it.

Returns:

  • (Hash<String, ApiPony::ResponseAttribute] a hash of each subype. keys are the names of the subtype, values are the attribute object that defines it)

    Hash<String, ApiPony::ResponseAttribute] a hash of each subype. keys are the names of the subtype, values are the attribute object that defines it



18
19
20
# File 'lib/apipony/documentation.rb', line 18

def subtypes
  Apipony::ResponseAttribute.defined_subtypes
end