Class: DocMyRoutes::RouteDocumentation

Inherits:
Object
  • Object
show all
Defined in:
lib/doc_my_routes/doc/route_documentation.rb

Overview

Class holding documentation information about a given route

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRouteDocumentation

Returns a new instance of RouteDocumentation.



8
9
10
11
12
13
# File 'lib/doc_my_routes/doc/route_documentation.rb', line 8

def initialize
  @status_codes = { 200 => DocMyRoutes::StatusCodeInfo::STATUS_CODES[200] }
  @hidden = false
  @produces = []
  @parameters = {}
end

Instance Attribute Details

#examplesObject (readonly)

Returns the value of attribute examples.



6
7
8
# File 'lib/doc_my_routes/doc/route_documentation.rb', line 6

def examples
  @examples
end

#examples_regexObject

Returns the value of attribute examples_regex.



4
5
6
# File 'lib/doc_my_routes/doc/route_documentation.rb', line 4

def examples_regex
  @examples_regex
end

#hiddenObject

Returns the value of attribute hidden.



4
5
6
# File 'lib/doc_my_routes/doc/route_documentation.rb', line 4

def hidden
  @hidden
end

#notesObject

Returns the value of attribute notes.



4
5
6
# File 'lib/doc_my_routes/doc/route_documentation.rb', line 4

def notes
  @notes
end

#notes_refObject

Returns the value of attribute notes_ref.



4
5
6
# File 'lib/doc_my_routes/doc/route_documentation.rb', line 4

def notes_ref
  @notes_ref
end

#parametersObject (readonly)

Returns the value of attribute parameters.



6
7
8
# File 'lib/doc_my_routes/doc/route_documentation.rb', line 6

def parameters
  @parameters
end

#producesObject

Returns the value of attribute produces.



4
5
6
# File 'lib/doc_my_routes/doc/route_documentation.rb', line 4

def produces
  @produces
end

#status_codesObject

Returns the value of attribute status_codes.



4
5
6
# File 'lib/doc_my_routes/doc/route_documentation.rb', line 4

def status_codes
  @status_codes
end

#summaryObject

Returns the value of attribute summary.



4
5
6
# File 'lib/doc_my_routes/doc/route_documentation.rb', line 4

def summary
  @summary
end

Instance Method Details

#add_parameter(name, options) ⇒ Object



38
39
40
# File 'lib/doc_my_routes/doc/route_documentation.rb', line 38

def add_parameter(name, options)
  @parameters[name] = options
end

#hidden?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/doc_my_routes/doc/route_documentation.rb', line 80

def hidden?
  !!@hidden
end

#present?Boolean

A route documentation object MUST have a summary, otherwise is not considered documented

Returns:

  • (Boolean)


17
18
19
# File 'lib/doc_my_routes/doc/route_documentation.rb', line 17

def present?
  !summary.nil?
end

#to_hashObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/doc_my_routes/doc/route_documentation.rb', line 21

def to_hash
  {
    summary: summary,
    notes: notes,
    status_codes: status_codes,
    examples_regex: examples_regex,
    produces: produces,
    examples: examples,
    parameters: parameters,
    hidden: hidden?
  }
end