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
26 27 28 29 30 31 32 33 34 |
# File 'lib/cassette/authentication/authorities.rb', line 26 def initialize(, = nil) = || Cassette.config. if .is_a?(String) = .gsub(/^\[(.*)\]$/, '\\1').split(',').map(&:strip) else = Array().map(&:strip) end end |
Class Method Details
.parse(authorities, base_authority = nil) ⇒ Object
8 9 10 |
# File 'lib/cassette/authentication/authorities.rb', line 8 def self.parse(, = nil) new(, ) end |
Instance Method Details
#authorities ⇒ Object
36 37 38 |
# File 'lib/cassette/authentication/authorities.rb', line 36 def .dup end |
#base ⇒ Object
12 13 14 |
# File 'lib/cassette/authentication/authorities.rb', line 12 def base .to_s.upcase end |
#has_raw_role?(role) ⇒ Boolean
16 17 18 19 |
# File 'lib/cassette/authentication/authorities.rb', line 16 def has_raw_role?(role) return true if ENV['NOAUTH'] .include?(role) end |
#has_role?(role) ⇒ Boolean
21 22 23 24 |
# File 'lib/cassette/authentication/authorities.rb', line 21 def has_role?(role) return true if ENV['NOAUTH'] has_raw_role?("#{base}_#{role.to_s.upcase.gsub('_', '-')}") end |