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) ⇒ Tag

Returns a new instance of Tag.



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

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

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

  @name =  tag ? tag.text : "#{@controller_class.controller_path}"
  @name, @route = @name.split(' ')

  @description = yard_object.docstring || ''
end

Instance Attribute Details

#controller_classObject (readonly)

Returns the value of attribute controller_class.



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

def controller_class
  @controller_class
end

#controller_nameObject (readonly)

Returns the value of attribute controller_name.



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

def controller_name
  @controller_name
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#routeObject (readonly)

Returns the value of attribute route.



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

def route
  @route
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