class ApiCanon::Document
Attributes
controller_name[R]
controller_path[R]
description[R]
documented_actions[RW]
documented_models[RW]
version[R]
Public Class Methods
new(controller_path, controller_name, opts={})
click to toggle source
# File lib/api_canon/document.rb, line 6 def initialize(controller_path, controller_name, opts={}) @controller_path = controller_path @controller_name = controller_name @version = opts[:version] self.display_name = opts[:as] @documented_models = {} @documented_actions = [] end
Public Instance Methods
add_action(documented_action)
click to toggle source
# File lib/api_canon/document.rb, line 35 def add_action(documented_action) @documented_actions << documented_action unless @documented_actions.map(&:action_name).include?(documented_action.action_name) end
add_model(documented_model)
click to toggle source
# File lib/api_canon/document.rb, line 38 def add_model(documented_model) @documented_models[documented_model.id] = documented_model end
describe(desc)
click to toggle source
The describe method is used as a DSL method in the document_controller block, use it to describe your API endpoint as a whole. @see ApiCanon::ClassMethods#document_controller
@param desc [String] The text to appear at the top of your API endpoint documentation page.
# File lib/api_canon/document.rb, line 18 def describe(desc) @description = desc end
display_name()
click to toggle source
# File lib/api_canon/document.rb, line 24 def display_name @display_name || @controller_name.titleize end
display_name=(dn)
click to toggle source
# File lib/api_canon/document.rb, line 27 def display_name=(dn) if dn.nil? @display_name = nil else dn = dn.to_s @display_name = (dn =~ /\A([a-z]*|[A-Z]*)\Z/ ? dn.titleize : dn) end end
link_path(link)
click to toggle source
# File lib/api_canon/document.rb, line 21 def link_path(link) @sidebar_link = link end