Sha256: a0fe97cdf0baee159081e04a7c318a5fe206eff970e78e9870b687878dfcd384

Contents?: true

Size: 798 Bytes

Versions: 5

Compression:

Stored size: 798 Bytes

Contents

module Swaggard
  module Swagger
    class Tag

      attr_accessor :name, :description

      attr_reader :controller_class

      def initialize(yard_object)
        @yard_name = yard_object.name

        controller_name = "#{yard_object.namespace}::#{yard_object.name}"
        controller_name.prepend("#{Swaggard.configuration.module_name}::") unless Swaggard.configuration.module_name.blank?

        @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

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

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
swaggard-0.5.3 lib/swaggard/swagger/tag.rb
swaggard-0.5.2 lib/swaggard/swagger/tag.rb
swaggard-0.5.1 lib/swaggard/swagger/tag.rb
swaggard-0.5.0 lib/swaggard/swagger/tag.rb
swaggard-0.4.0 lib/swaggard/swagger/tag.rb