Class: Brainstem::ApiDocs::EndpointCollection
Instance Attribute Summary
#formatters
#atlas
Instance Method Summary
collapse
#formatted_as, #formatter_type, #valid_options
#<<, #each, #each_filename, #each_formatted, #each_formatted_with_filename, #filenames, #formatted, #formatted_with_filename, #initialize, #last, with_members
#initialize, #valid_options
Instance Method Details
#create_from_route(route, controller) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 20
def create_from_route(route, controller)
Endpoint.new(atlas) 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
10
11
12
13
14
15
16
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 10
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
30
31
32
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 30
def only_documentable
self.class.with_members(atlas, reject(&:nodoc?))
end
|
#sorted ⇒ Object
38
39
40
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 38
def sorted
self.class.with_members(atlas, sort)
end
|
#sorted_with_actions_in_controller(const) ⇒ Object
46
47
48
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 46
def sorted_with_actions_in_controller(const)
with_actions_in_controller(const).sorted
end
|
#with_actions_in_controller(const) ⇒ Object
42
43
44
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 42
def with_actions_in_controller(const)
self.class.with_members(atlas, reject { |m| !const.method_defined?(m.action) })
end
|
#with_declared_presented_class ⇒ Object
34
35
36
|
# File 'lib/brainstem/api_docs/endpoint_collection.rb', line 34
def with_declared_presented_class
self.class.with_members(atlas, reject { |m| m.declared_presented_class.nil? })
end
|