Class: Cassette::Authentication::Authorities
- Inherits:
-
Object
- Object
- Cassette::Authentication::Authorities
- Defined in:
- lib/cassette/authentication/authorities.rb
Class Method Summary collapse
Instance Method Summary collapse
- #authorities ⇒ Object
- #base ⇒ Object
- #has_raw_role?(role) ⇒ Boolean
- #has_role?(role) ⇒ Boolean
-
#initialize(authorities, base_authority = nil) ⇒ Authorities
constructor
A new instance of Authorities.
Constructor Details
#initialize(authorities, base_authority = nil) ⇒ Authorities
Returns a new instance of Authorities.
24 25 26 27 28 29 30 31 32 |
# File 'lib/cassette/authentication/authorities.rb', line 24 def initialize(, = nil) @base_authority = || Cassette.config. if .is_a?(String) @authorities = .gsub(/^\[(.*)\]$/, '\\1').split(',').map(&:strip) else @authorities = Array().map(&:strip) end end |
Class Method Details
.parse(authorities, base_authority = nil) ⇒ Object
6 7 8 |
# File 'lib/cassette/authentication/authorities.rb', line 6 def self.parse(, = nil) new(, ) end |
Instance Method Details
#authorities ⇒ Object
34 35 36 |
# File 'lib/cassette/authentication/authorities.rb', line 34 def @authorities.dup end |
#base ⇒ Object
10 11 12 |
# File 'lib/cassette/authentication/authorities.rb', line 10 def base @base_authority.to_s.upcase end |
#has_raw_role?(role) ⇒ Boolean
14 15 16 17 |
# File 'lib/cassette/authentication/authorities.rb', line 14 def has_raw_role?(role) return true if ENV['NOAUTH'] @authorities.include?(role) end |
#has_role?(role) ⇒ Boolean
19 20 21 22 |
# File 'lib/cassette/authentication/authorities.rb', line 19 def has_role?(role) return true if ENV['NOAUTH'] has_raw_role?("#{base}_#{role.to_s.upcase.gsub('_', '-')}") end |