Class: Brainstem::ApiDocs::Controller
Instance Attribute Summary collapse
#formatters
Instance Method Summary
collapse
#formatted_as, #formatter_type
Constructor Details
#initialize(atlas, options = {}) {|_self| ... } ⇒ Controller
Returns a new instance of Controller.
14
15
16
17
18
19
|
# File 'lib/brainstem/api_docs/controller.rb', line 14
def initialize(atlas, options = {})
self.atlas = atlas
self.endpoints = EndpointCollection.new(atlas)
super options
yield self if block_given?
end
|
Instance Attribute Details
#atlas ⇒ Object
Returns the value of attribute atlas.
21
22
23
|
# File 'lib/brainstem/api_docs/controller.rb', line 21
def atlas
@atlas
end
|
#const ⇒ Object
Returns the value of attribute const.
21
22
23
|
# File 'lib/brainstem/api_docs/controller.rb', line 21
def const
@const
end
|
#endpoints ⇒ Object
Returns the value of attribute endpoints.
21
22
23
|
# File 'lib/brainstem/api_docs/controller.rb', line 21
def endpoints
@endpoints
end
|
#filename_link_pattern ⇒ Object
70
71
72
|
# File 'lib/brainstem/api_docs/controller.rb', line 70
def filename_link_pattern
@filename_link_pattern ||= Brainstem::ApiDocs.controller_filename_link_pattern
end
|
#filename_pattern ⇒ Object
Returns the value of attribute filename_pattern.
21
22
23
|
# File 'lib/brainstem/api_docs/controller.rb', line 21
def filename_pattern
@filename_pattern
end
|
#include_internal ⇒ Object
Returns the value of attribute include_internal.
21
22
23
|
# File 'lib/brainstem/api_docs/controller.rb', line 21
def include_internal
@include_internal
end
|
#name ⇒ Object
Returns the value of attribute name.
21
22
23
|
# File 'lib/brainstem/api_docs/controller.rb', line 21
def name
@name
end
|
Instance Method Details
#add_endpoint(endpoint) ⇒ Object
Adds an existing endpoint to its endpoint collection.
45
46
47
|
# File 'lib/brainstem/api_docs/controller.rb', line 45
def add_endpoint(endpoint)
self.endpoints << endpoint
end
|
#contextual_documentation(key) ⇒ Object
Returns a key if it exists and is documentable.
104
105
106
107
108
|
# File 'lib/brainstem/api_docs/controller.rb', line 104
def contextual_documentation(key)
default_configuration.has_key?(key) &&
!nodoc_for?(default_configuration[key]) &&
default_configuration[key][:info]
end
|
#default_configuration ⇒ Object
77
78
79
|
# File 'lib/brainstem/api_docs/controller.rb', line 77
def default_configuration
configuration[:_default]
end
|
#description ⇒ Object
89
90
91
|
# File 'lib/brainstem/api_docs/controller.rb', line 89
def description
contextual_documentation(:description) || ""
end
|
#extension ⇒ Object
62
63
64
|
# File 'lib/brainstem/api_docs/controller.rb', line 62
def extension
@extension ||= Brainstem::ApiDocs.output_extension
end
|
#nodoc? ⇒ Boolean
81
82
83
|
# File 'lib/brainstem/api_docs/controller.rb', line 81
def nodoc?
nodoc_for?(default_configuration)
end
|
#suggested_filename(format) ⇒ Object
49
50
51
52
53
54
|
# File 'lib/brainstem/api_docs/controller.rb', line 49
def suggested_filename(format)
filename_pattern
.gsub('{{namespace}}', const.to_s.deconstantize.underscore)
.gsub('{{name}}', name.to_s.split("/").last)
.gsub('{{extension}}', extension)
end
|
#suggested_filename_link(format) ⇒ Object
56
57
58
59
60
|
# File 'lib/brainstem/api_docs/controller.rb', line 56
def suggested_filename_link(format)
filename_link_pattern
.gsub('{{name}}', name.to_s)
.gsub('{{extension}}', extension)
end
|
#tag ⇒ Object
93
94
95
|
# File 'lib/brainstem/api_docs/controller.rb', line 93
def tag
default_configuration[:tag]
end
|
#tag_groups ⇒ Object
97
98
99
|
# File 'lib/brainstem/api_docs/controller.rb', line 97
def tag_groups
default_configuration[:tag_groups]
end
|
#title ⇒ Object
85
86
87
|
# File 'lib/brainstem/api_docs/controller.rb', line 85
def title
contextual_documentation(:title) || const.to_s.demodulize
end
|
#valid_options ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/brainstem/api_docs/controller.rb', line 31
def valid_options
super | [
:const,
:name,
:formatters,
:filename_pattern,
:filename_link_pattern,
:include_internal
]
end
|
#valid_sorted_endpoints ⇒ Object
110
111
112
|
# File 'lib/brainstem/api_docs/controller.rb', line 110
def valid_sorted_endpoints
endpoints.sorted_with_actions_in_controller(const)
end
|