Class: ApiCanon::Document
- Inherits:
-
Object
- Object
- ApiCanon::Document
- Includes:
- ActiveModel::Serialization
- Defined in:
- lib/api_canon/document.rb
Instance Attribute Summary collapse
-
#controller_name ⇒ Object
readonly
Returns the value of attribute controller_name.
-
#controller_path ⇒ Object
readonly
Returns the value of attribute controller_path.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#documented_actions ⇒ Object
Returns the value of attribute documented_actions.
-
#sidebar_link ⇒ Object
readonly
Returns the value of attribute sidebar_link.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #add_action(documented_action) ⇒ Object
-
#describe(desc) ⇒ Object
The describe method is used as a DSL method in the document_controller block, use it to describe your API endpoint as a whole.
- #display_name ⇒ Object
- #display_name=(dn) ⇒ Object
-
#initialize(controller_path, controller_name, opts = {}) ⇒ Document
constructor
A new instance of Document.
- #link_path(link) ⇒ Object
Constructor Details
#initialize(controller_path, controller_name, opts = {}) ⇒ Document
Returns a new instance of Document.
6 7 8 9 10 11 12 |
# 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_actions = [] end |
Instance Attribute Details
#controller_name ⇒ Object (readonly)
Returns the value of attribute controller_name.
4 5 6 |
# File 'lib/api_canon/document.rb', line 4 def controller_name @controller_name end |
#controller_path ⇒ Object (readonly)
Returns the value of attribute controller_path.
4 5 6 |
# File 'lib/api_canon/document.rb', line 4 def controller_path @controller_path end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
4 5 6 |
# File 'lib/api_canon/document.rb', line 4 def description @description end |
#documented_actions ⇒ Object
Returns the value of attribute documented_actions.
5 6 7 |
# File 'lib/api_canon/document.rb', line 5 def documented_actions @documented_actions end |
#sidebar_link ⇒ Object (readonly)
Returns the value of attribute sidebar_link.
4 5 6 |
# File 'lib/api_canon/document.rb', line 4 def @sidebar_link end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
4 5 6 |
# File 'lib/api_canon/document.rb', line 4 def version @version end |
Instance Method Details
#add_action(documented_action) ⇒ Object
34 35 36 |
# File 'lib/api_canon/document.rb', line 34 def add_action(documented_action) @documented_actions << documented_action unless @documented_actions.map(&:action_name).include?(documented_action.action_name) end |
#describe(desc) ⇒ Object
The describe method is used as a DSL method in the document_controller block, use it to describe your API endpoint as a whole.
17 18 19 |
# File 'lib/api_canon/document.rb', line 17 def describe(desc) @description = desc end |
#display_name ⇒ Object
23 24 25 |
# File 'lib/api_canon/document.rb', line 23 def display_name @display_name || @controller_name.titleize end |
#display_name=(dn) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/api_canon/document.rb', line 26 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) ⇒ Object
20 21 22 |
# File 'lib/api_canon/document.rb', line 20 def link_path(link) @sidebar_link = link end |