Class: Interdasting::Documentation::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/interdasting/documentation/action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#commentsObject (readonly)

Returns the value of attribute comments.



6
7
8
# File 'lib/interdasting/documentation/action.rb', line 6

def comments
  @comments
end

#controllerObject (readonly)

Returns the value of attribute controller.



5
6
7
# File 'lib/interdasting/documentation/action.rb', line 5

def controller
  @controller
end

#nameObject (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_methodObject



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

#methodsObject



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