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.
15
16
17
18
19
20
|
# File 'lib/brainstem/api_docs/controller.rb', line 15
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.
23
24
25
|
# File 'lib/brainstem/api_docs/controller.rb', line 23
def atlas
@atlas
end
|
#const ⇒ Object
Returns the value of attribute const.
23
24
25
|
# File 'lib/brainstem/api_docs/controller.rb', line 23
def const
@const
end
|
#endpoints ⇒ Object
Returns the value of attribute endpoints.
23
24
25
|
# File 'lib/brainstem/api_docs/controller.rb', line 23
def endpoints
@endpoints
end
|
#filename_link_pattern ⇒ Object
78
79
80
|
# File 'lib/brainstem/api_docs/controller.rb', line 78
def filename_link_pattern
@filename_link_pattern ||= Brainstem::ApiDocs.controller_filename_link_pattern
end
|
#filename_pattern ⇒ Object
Returns the value of attribute filename_pattern.
23
24
25
|
# File 'lib/brainstem/api_docs/controller.rb', line 23
def filename_pattern
@filename_pattern
end
|
#name ⇒ Object
Returns the value of attribute name.
23
24
25
|
# File 'lib/brainstem/api_docs/controller.rb', line 23
def name
@name
end
|
Instance Method Details
#add_endpoint(endpoint) ⇒ Object
Adds an existing endpoint to its endpoint collection.
48
49
50
|
# File 'lib/brainstem/api_docs/controller.rb', line 48
def add_endpoint(endpoint)
self.endpoints << endpoint
end
|
#contextual_documentation(key) ⇒ Object
Returns a key if it exists and is documentable.
110
111
112
113
114
|
# File 'lib/brainstem/api_docs/controller.rb', line 110
def contextual_documentation(key)
default_configuration.has_key?(key) &&
!default_configuration[key][:nodoc] &&
default_configuration[key][:info]
end
|
#default_configuration ⇒ Object
87
88
89
|
# File 'lib/brainstem/api_docs/controller.rb', line 87
def default_configuration
configuration[:_default]
end
|
#description ⇒ Object
102
103
104
|
# File 'lib/brainstem/api_docs/controller.rb', line 102
def description
contextual_documentation(:description) || ""
end
|
#extension ⇒ Object
68
69
70
|
# File 'lib/brainstem/api_docs/controller.rb', line 68
def extension
@extension ||= Brainstem::ApiDocs.output_extension
end
|
#nodoc? ⇒ Boolean
92
93
94
|
# File 'lib/brainstem/api_docs/controller.rb', line 92
def nodoc?
default_configuration[:nodoc]
end
|
#suggested_filename(format) ⇒ Object
53
54
55
56
57
58
|
# File 'lib/brainstem/api_docs/controller.rb', line 53
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
61
62
63
64
65
|
# File 'lib/brainstem/api_docs/controller.rb', line 61
def suggested_filename_link(format)
filename_link_pattern
.gsub('{{name}}', name.to_s)
.gsub('{{extension}}', extension)
end
|
#title ⇒ Object
97
98
99
|
# File 'lib/brainstem/api_docs/controller.rb', line 97
def title
contextual_documentation(:title) || const.to_s.demodulize
end
|
#valid_options ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/brainstem/api_docs/controller.rb', line 34
def valid_options
super | [
:const,
:name,
:formatters,
:filename_pattern,
:filename_link_pattern
]
end
|
#valid_sorted_endpoints ⇒ Object
117
118
119
|
# File 'lib/brainstem/api_docs/controller.rb', line 117
def valid_sorted_endpoints
endpoints.sorted_with_actions_in_controller(const)
end
|