Class: Brainstem::ApiDocs::EndpointCollection
Instance Attribute Summary collapse
#formatters
#atlas
Instance Method Summary
collapse
#formatted_as, #formatter_type
#<<, #each, #each_filename, #each_formatted, #each_formatted_with_filename, #filenames, #formatted, #formatted_with_filename, #initialize, #last, with_members
#initialize
Instance Attribute Details
#include_internal ⇒ Object
Returns the value of attribute include_internal.
10
11
12
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 10
def include_internal
@include_internal
end
|
Instance Method Details
#create_from_route(route, controller) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 28
def create_from_route(route, controller)
Endpoint.new(atlas, include_internal: self.include_internal) do |ep|
ep.path = route[:path]
ep.http_methods = route[:http_methods]
ep.controller = controller
ep.controller_name = route[:controller_name]
ep.action = route[:action]
end.tap { |endpoint| self.<< endpoint }
end
|
#find_from_route(route) ⇒ Object
Also known as:
find_by_route
18
19
20
21
22
23
24
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 18
def find_from_route(route)
find do |endpoint|
endpoint.path == route[:path] &&
endpoint.controller.const == route[:controller] &&
endpoint.action == route[:action]
end
end
|
#only_documentable ⇒ Object
38
39
40
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 38
def only_documentable
self.class.with_members(atlas, reject(&:nodoc?))
end
|
#sorted ⇒ Object
46
47
48
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 46
def sorted
self.class.with_members(atlas, sort)
end
|
#sorted_with_actions_in_controller(const) ⇒ Object
54
55
56
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 54
def sorted_with_actions_in_controller(const)
with_actions_in_controller(const).sorted
end
|
#valid_options ⇒ Object
12
13
14
15
16
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 12
def valid_options
super | [
:include_internal
]
end
|
#with_actions_in_controller(const) ⇒ Object
50
51
52
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 50
def with_actions_in_controller(const)
self.class.with_members(atlas, reject { |m| !const.method_defined?(m.action) })
end
|
#with_declared_presented_class ⇒ Object
42
43
44
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 42
def with_declared_presented_class
self.class.with_members(atlas, reject { |m| m.declared_presented_class.nil? })
end
|