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
68
69
70
|
# File 'lib/brainstem/api_docs/controller.rb', line 68
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
|
#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.
43
44
45
|
# File 'lib/brainstem/api_docs/controller.rb', line 43
def add_endpoint(endpoint)
self.endpoints << endpoint
end
|
#contextual_documentation(key) ⇒ Object
Returns a key if it exists and is documentable.
102
103
104
105
106
|
# File 'lib/brainstem/api_docs/controller.rb', line 102
def contextual_documentation(key)
default_configuration.has_key?(key) &&
!default_configuration[key][:nodoc] &&
default_configuration[key][:info]
end
|
#default_configuration ⇒ Object
75
76
77
|
# File 'lib/brainstem/api_docs/controller.rb', line 75
def default_configuration
configuration[:_default]
end
|
#description ⇒ Object
87
88
89
|
# File 'lib/brainstem/api_docs/controller.rb', line 87
def description
contextual_documentation(:description) || ""
end
|
#extension ⇒ Object
60
61
62
|
# File 'lib/brainstem/api_docs/controller.rb', line 60
def extension
@extension ||= Brainstem::ApiDocs.output_extension
end
|
#nodoc? ⇒ Boolean
79
80
81
|
# File 'lib/brainstem/api_docs/controller.rb', line 79
def nodoc?
default_configuration[:nodoc]
end
|
#suggested_filename(format) ⇒ Object
47
48
49
50
51
52
|
# File 'lib/brainstem/api_docs/controller.rb', line 47
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
54
55
56
57
58
|
# File 'lib/brainstem/api_docs/controller.rb', line 54
def suggested_filename_link(format)
filename_link_pattern
.gsub('{{name}}', name.to_s)
.gsub('{{extension}}', extension)
end
|
#tag ⇒ Object
91
92
93
|
# File 'lib/brainstem/api_docs/controller.rb', line 91
def tag
default_configuration[:tag]
end
|
#tag_groups ⇒ Object
95
96
97
|
# File 'lib/brainstem/api_docs/controller.rb', line 95
def tag_groups
default_configuration[:tag_groups]
end
|
#title ⇒ Object
83
84
85
|
# File 'lib/brainstem/api_docs/controller.rb', line 83
def title
contextual_documentation(:title) || const.to_s.demodulize
end
|
#valid_options ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/brainstem/api_docs/controller.rb', line 30
def valid_options
super | [
:const,
:name,
:formatters,
:filename_pattern,
:filename_link_pattern
]
end
|
#valid_sorted_endpoints ⇒ Object
108
109
110
|
# File 'lib/brainstem/api_docs/controller.rb', line 108
def valid_sorted_endpoints
endpoints.sorted_with_actions_in_controller(const)
end
|