Class: Interdasting::Documentation::Action
- Inherits:
-
Object
- Object
- Interdasting::Documentation::Action
- Defined in:
- lib/interdasting/documentation/action.rb
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #default_method ⇒ Object
- #description(method = default_method) ⇒ Object
-
#initialize(name, comments, methods, params, controller) ⇒ Action
constructor
A new instance of Action.
- #methods ⇒ Object
- #params(method = default_method) ⇒ Object
- #url(method = default_method) ⇒ Object
Constructor Details
#initialize(name, comments, methods, params, controller) ⇒ Action
Returns a new instance of Action.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/interdasting/documentation/action.rb', line 8 def initialize(name, comments, methods, params, controller) @name = name @comments = comments @methods = sanitize_methods(methods) @params = params @params.delete(:version) if params @params = @params.presence @controller = controller generate end |
Instance Attribute Details
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
6 7 8 |
# File 'lib/interdasting/documentation/action.rb', line 6 def comments @comments end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
5 6 7 |
# File 'lib/interdasting/documentation/action.rb', line 5 def controller @controller end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/interdasting/documentation/action.rb', line 4 def name @name end |
Instance Method Details
#default_method ⇒ Object
33 34 35 |
# File 'lib/interdasting/documentation/action.rb', line 33 def default_method methods.first || 'GET' end |
#description(method = default_method) ⇒ Object
24 25 26 |
# File 'lib/interdasting/documentation/action.rb', line 24 def description(method = default_method) (@doc[method] && @doc[method]['DOC']) || @doc['DOC'] end |
#methods ⇒ Object
37 38 39 40 |
# File 'lib/interdasting/documentation/action.rb', line 37 def methods @methods.presence || @doc.keys.select { |m| Parser.http_keywords.include?(m) } end |
#params(method = default_method) ⇒ Object
28 29 30 31 |
# File 'lib/interdasting/documentation/action.rb', line 28 def params(method = default_method) (@doc[method] && @doc[method]['PARAMS']) || @doc['PARAMS'] || @params end |
#url(method = default_method) ⇒ Object
19 20 21 22 |
# File 'lib/interdasting/documentation/action.rb', line 19 def url(method = default_method) (@doc[method] && @doc[method]['URL']) || @doc['URL'] || router_url(method) end |