Class: Swagger::Data::Scopes
- Inherits:
-
Object
- Object
- Object
- Swagger::Data::Scopes
show all
- Defined in:
- lib/ruby-swagger/data/scopes.rb
Overview
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Object
attr_swagger, #bulk_set, #swagger_attributes, #to_json, #to_swagger, #to_yaml
Constructor Details
#initialize ⇒ Scopes
Returns a new instance of Scopes.
5
6
7
|
# File 'lib/ruby-swagger/data/scopes.rb', line 5
def initialize
@scopes = {}
end
|
Class Method Details
.parse(scopes) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/ruby-swagger/data/scopes.rb', line 9
def self.parse(scopes)
return nil unless scopes
scope = Swagger::Data::Scopes.new
scopes.each do |scope_name, scope_value|
scope.add_scope(scope_name, scope_value)
end
scope
end
|
Instance Method Details
#[](scope) ⇒ Object
28
29
30
|
# File 'lib/ruby-swagger/data/scopes.rb', line 28
def [](scope)
@scopes[scope]
end
|
#add_scope(scope_name, scope_value) ⇒ Object
21
22
23
24
25
26
|
# File 'lib/ruby-swagger/data/scopes.rb', line 21
def add_scope(scope_name, scope_value)
raise ArgumentError.new('Swagger::Data::Scopes#add_scope - scope_name is nil') unless scope_name
raise ArgumentError.new('Swagger::Data::Scopes#add_scope - scope_value is nil') unless scope_value
@scopes[scope_name] = scope_value
end
|
#as_swagger ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/ruby-swagger/data/scopes.rb', line 32
def as_swagger
swagger_scopes = {}
@scopes.each do |scope_k, scope_v|
swagger_scopes[scope_k] = scope_v
end
swagger_scopes
end
|