Class: SwaggerYard::Authorization

Inherits:
Object
  • Object
show all
Defined in:
lib/swagger_yard/authorization.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, name, description) ⇒ Authorization

Returns a new instance of Authorization.



10
11
12
13
# File 'lib/swagger_yard/authorization.rb', line 10

def initialize(type, name, description)
  @type, @name, @description = type, name, description
  @key = nil
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/swagger_yard/authorization.rb', line 3

def description
  @description
end

#idObject



23
24
25
# File 'lib/swagger_yard/authorization.rb', line 23

def id
  @id ||= api_key_id || name
end

#keyObject



15
16
17
18
19
20
21
# File 'lib/swagger_yard/authorization.rb', line 15

def key
  return @key if @key
  return nil unless @description
  return nil unless @type =~ /api_?key|bearer/i
  @key, @description = @description.split(' ', 2)
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/swagger_yard/authorization.rb', line 3

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/swagger_yard/authorization.rb', line 3

def type
  @type
end

Class Method Details

.from_yard_object(yard_object) ⇒ Object



6
7
8
# File 'lib/swagger_yard/authorization.rb', line 6

def self.from_yard_object(yard_object)
  new(yard_object.types.first, yard_object.name, yard_object.text)
end