Class: Swaggard::Swagger::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/swaggard/swagger/tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(yard_object) ⇒ Tag

Returns a new instance of Tag.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/swaggard/swagger/tag.rb', line 9

def initialize(yard_object)
  controller_name = "#{yard_object.namespace}::#{yard_object.name}"

  @yard_name = yard_object.name
  @controller_class = controller_name.constantize

  tag = yard_object.tags.find { |tag| tag.tag_name == 'tag' }

  @name =  tag ? tag.text : "#{@controller_class.controller_path}"
  @description = yard_object.docstring || ''
end

Instance Attribute Details

#controller_classObject (readonly)

Returns the value of attribute controller_class.



7
8
9
# File 'lib/swaggard/swagger/tag.rb', line 7

def controller_class
  @controller_class
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/swaggard/swagger/tag.rb', line 5

def description
  @description
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/swaggard/swagger/tag.rb', line 5

def name
  @name
end

Instance Method Details

#to_docObject



21
22
23
24
25
26
# File 'lib/swaggard/swagger/tag.rb', line 21

def to_doc
  {
    'name'        => @name,
    'description' => @description
  }
end