class Brainstem::ApiDocs::Controller
Attributes
atlas[RW]
const[RW]
endpoints[RW]
filename_link_pattern[W]
filename_pattern[RW]
include_internal[RW]
name[RW]
Public Class Methods
new(atlas, options = {}) { |self| ... }
click to toggle source
Calls superclass method
Brainstem::Concerns::Optional::new
# 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
Public Instance Methods
add_endpoint(endpoint)
click to toggle source
Adds an existing endpoint to its endpoint collection.
# File lib/brainstem/api_docs/controller.rb, line 45 def add_endpoint(endpoint) self.endpoints << endpoint end
contextual_documentation(key)
click to toggle source
Returns a key if it exists and is documentable.
# 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()
click to toggle source
# File lib/brainstem/api_docs/controller.rb, line 77 def default_configuration configuration[:_default] end
description()
click to toggle source
# File lib/brainstem/api_docs/controller.rb, line 89 def description contextual_documentation(:description) || "" end
extension()
click to toggle source
# File lib/brainstem/api_docs/controller.rb, line 62 def extension @extension ||= Brainstem::ApiDocs.output_extension end
filename_link_pattern()
click to toggle source
# File lib/brainstem/api_docs/controller.rb, line 70 def filename_link_pattern @filename_link_pattern ||= Brainstem::ApiDocs.controller_filename_link_pattern end
nodoc?()
click to toggle source
# File lib/brainstem/api_docs/controller.rb, line 81 def nodoc? nodoc_for?(default_configuration) end
suggested_filename(format)
click to toggle source
# 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)
click to toggle source
# 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()
click to toggle source
# File lib/brainstem/api_docs/controller.rb, line 93 def tag default_configuration[:tag] end
tag_groups()
click to toggle source
# File lib/brainstem/api_docs/controller.rb, line 97 def tag_groups default_configuration[:tag_groups] end
title()
click to toggle source
# File lib/brainstem/api_docs/controller.rb, line 85 def title contextual_documentation(:title) || const.to_s.demodulize end
valid_options()
click to toggle source
Calls superclass method
Brainstem::Concerns::Formattable#valid_options
# 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()
click to toggle source
# File lib/brainstem/api_docs/controller.rb, line 110 def valid_sorted_endpoints endpoints.sorted_with_actions_in_controller(const) end
Private Instance Methods
nodoc_for?(config)
click to toggle source
# File lib/brainstem/api_docs/controller.rb, line 116 def nodoc_for?(config) !!(config[:nodoc] || (config[:internal] && !include_internal)) end