Class: Rambo::RamlModels::SecurityScheme
- Inherits:
-
Object
- Object
- Rambo::RamlModels::SecurityScheme
- Defined in:
- lib/rambo/raml_models/security_scheme.rb
Instance Attribute Summary collapse
-
#schema ⇒ Object
writeonly
Sets the attribute schema.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #api_token_header ⇒ Object
- #headers ⇒ Object
-
#initialize(raml, options = {}) ⇒ SecurityScheme
constructor
A new instance of SecurityScheme.
- #use_token! ⇒ Object
Constructor Details
#initialize(raml, options = {}) ⇒ SecurityScheme
Returns a new instance of SecurityScheme.
7 8 9 10 11 |
# File 'lib/rambo/raml_models/security_scheme.rb', line 7 def initialize(raml, ={}) = @schema, @title = raml.last.fetch("describedBy", {}), raml.first use_token! end |
Instance Attribute Details
#schema=(value) ⇒ Object
Sets the attribute schema
4 5 6 |
# File 'lib/rambo/raml_models/security_scheme.rb', line 4 def schema=(value) @schema = value end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/rambo/raml_models/security_scheme.rb', line 4 def title @title end |
Instance Method Details
#api_token_header ⇒ Object
19 20 21 22 23 |
# File 'lib/rambo/raml_models/security_scheme.rb', line 19 def api_token_header return unless h = schema.fetch("headers", nil) h.find {|key, value| key.match(/(token|key)/i) }.first end |
#headers ⇒ Object
25 26 27 |
# File 'lib/rambo/raml_models/security_scheme.rb', line 25 def headers @headers ||= Rambo::RamlModels::Headers.new(schema.fetch("headers") || {}) end |
#use_token! ⇒ Object
13 14 15 16 17 |
# File 'lib/rambo/raml_models/security_scheme.rb', line 13 def use_token! if schema.fetch("headers", nil) schema.fetch("headers")[api_token_header] = [:token] end end |