Class: Apiwork::API::Info
- Inherits:
-
Object
- Object
- Apiwork::API::Info
- Defined in:
- lib/apiwork/api/info.rb,
lib/apiwork/api/info/server.rb,
lib/apiwork/api/info/contact.rb,
lib/apiwork/api/info/license.rb
Overview
Block context for defining API metadata.
Used within the ‘info` block in Base.
Defined Under Namespace
Classes: Contact, License, Server
Instance Method Summary collapse
-
#contact {|contact| ... } ⇒ Contact?
The API contact.
-
#deprecated! ⇒ void
Marks the API as deprecated.
-
#deprecated? ⇒ Boolean
Whether the API is deprecated.
-
#description(value = nil) ⇒ String?
The API description.
-
#initialize ⇒ Info
constructor
A new instance of Info.
-
#license {|license| ... } ⇒ License?
The API license.
-
#server {|server| ... } ⇒ Array<Server>
Defines a server for the API.
-
#summary(value = nil) ⇒ String?
The API summary.
-
#tags(*values) ⇒ Array<String>
The API tags.
-
#terms_of_service(value = nil) ⇒ String?
The API terms of service.
-
#title(value = nil) ⇒ String?
The API title.
-
#version(value = nil) ⇒ String?
The API version.
Constructor Details
#initialize ⇒ Info
Returns a new instance of Info.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/apiwork/api/info.rb', line 10 def initialize @contact = nil @deprecated = false @description = nil @license = nil @servers = [] @summary = nil @tags = [] @terms_of_service = nil @title = nil @version = nil end |
Instance Method Details
#contact {|contact| ... } ⇒ Contact?
The API contact.
89 90 91 92 93 94 95 |
# File 'lib/apiwork/api/info.rb', line 89 def contact(&block) return @contact unless block @contact = Contact.new block.arity.positive? ? yield(@contact) : @contact.instance_eval(&block) @contact end |
#deprecated! ⇒ void
This method returns an undefined value.
Marks the API as deprecated.
208 209 210 |
# File 'lib/apiwork/api/info.rb', line 208 def deprecated! @deprecated = true end |
#deprecated? ⇒ Boolean
Whether the API is deprecated.
216 217 218 |
# File 'lib/apiwork/api/info.rb', line 216 def deprecated? @deprecated end |
#description(value = nil) ⇒ String?
The API description.
177 178 179 180 181 |
# File 'lib/apiwork/api/info.rb', line 177 def description(value = nil) return @description if value.nil? @description = value end |
#license {|license| ... } ⇒ License?
The API license.
115 116 117 118 119 120 121 |
# File 'lib/apiwork/api/info.rb', line 115 def license(&block) return @license unless block @license = License.new block.arity.positive? ? yield(@license) : @license.instance_eval(&block) @license end |
#server {|server| ... } ⇒ Array<Server>
Defines a server for the API.
Can be called multiple times.
143 144 145 146 147 148 149 |
# File 'lib/apiwork/api/info.rb', line 143 def server(&block) return @servers unless block server = Server.new block.arity.positive? ? yield(server) : server.instance_eval(&block) @servers << server end |
#summary(value = nil) ⇒ String?
The API summary.
161 162 163 164 165 |
# File 'lib/apiwork/api/info.rb', line 161 def summary(value = nil) return @summary if value.nil? @summary = value end |
#tags(*values) ⇒ Array<String>
The API tags.
193 194 195 196 197 |
# File 'lib/apiwork/api/info.rb', line 193 def (*values) return @tags if values.empty? @tags = values.flatten end |
#terms_of_service(value = nil) ⇒ String?
The API terms of service.
65 66 67 68 69 |
# File 'lib/apiwork/api/info.rb', line 65 def terms_of_service(value = nil) return @terms_of_service if value.nil? @terms_of_service = value end |
#title(value = nil) ⇒ String?
The API title.
33 34 35 36 37 |
# File 'lib/apiwork/api/info.rb', line 33 def title(value = nil) return @title if value.nil? @title = value end |
#version(value = nil) ⇒ String?
The API version.
49 50 51 52 53 |
# File 'lib/apiwork/api/info.rb', line 49 def version(value = nil) return @version if value.nil? @version = value end |