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.
-
#documented_models ⇒ Object
Returns the value of attribute documented_models.
-
#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
- #add_model(documented_model) ⇒ 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 13 |
# 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 |
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 |
#documented_models ⇒ Object
Returns the value of attribute documented_models.
5 6 7 |
# File 'lib/api_canon/document.rb', line 5 def documented_models @documented_models 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
35 36 37 |
# 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) ⇒ Object
38 39 40 |
# File 'lib/api_canon/document.rb', line 38 def add_model(documented_model) @documented_models[documented_model.id] = documented_model 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.
18 19 20 |
# File 'lib/api_canon/document.rb', line 18 def describe(desc) @description = desc end |
#display_name ⇒ Object
24 25 26 |
# File 'lib/api_canon/document.rb', line 24 def display_name @display_name || @controller_name.titleize end |
#display_name=(dn) ⇒ Object
27 28 29 30 31 32 33 34 |
# 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) ⇒ Object
21 22 23 |
# File 'lib/api_canon/document.rb', line 21 def link_path(link) @sidebar_link = link end |