Class: GoogleSAAuth::Scope
- Inherits:
-
Object
- Object
- GoogleSAAuth::Scope
- Defined in:
- lib/google-sa-auth/scope.rb
Instance Attribute Summary collapse
-
#api_info ⇒ Object
Returns the value of attribute api_info.
-
#scope_urls ⇒ Object
Returns the value of attribute scope_urls.
Instance Method Summary collapse
- #by_extension(extension) ⇒ Object
- #full_access ⇒ Object
-
#initialize(name) ⇒ Scope
constructor
A new instance of Scope.
- #read_only ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(name) ⇒ Scope
Returns a new instance of Scope.
6 7 8 |
# File 'lib/google-sa-auth/scope.rb', line 6 def initialize(name) get_api_info(name.to_s) end |
Instance Attribute Details
#api_info ⇒ Object
Returns the value of attribute api_info.
5 6 7 |
# File 'lib/google-sa-auth/scope.rb', line 5 def api_info @api_info end |
#scope_urls ⇒ Object
Returns the value of attribute scope_urls.
5 6 7 |
# File 'lib/google-sa-auth/scope.rb', line 5 def scope_urls @scope_urls end |
Instance Method Details
#by_extension(extension) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/google-sa-auth/scope.rb', line 24 def by_extension(extension) # If extension is nil, then we can just return full access. return full_access if extension.nil? # Try to find a scope by extension, e.g. ".readonly" self.scope_urls.each do |url| return url if url =~ /\.#{extension}$/i end nil end |
#full_access ⇒ Object
14 15 16 17 |
# File 'lib/google-sa-auth/scope.rb', line 14 def full_access # Get the shortest scope, which theoretically will be full permissions. self.scope_urls.sort_by {|url| url.length}.first end |
#read_only ⇒ Object
19 20 21 22 |
# File 'lib/google-sa-auth/scope.rb', line 19 def read_only # Simply wrapper for .readonly permissions. by_extension('readonly') end |
#url ⇒ Object
10 11 12 |
# File 'lib/google-sa-auth/scope.rb', line 10 def url full_access end |