Class: SqAuth::SqAuthSession
- Inherits:
-
Object
- Object
- SqAuth::SqAuthSession
- Defined in:
- lib/sq_auth/sq_auth_session.rb
Instance Attribute Summary collapse
-
#session_value ⇒ Object
readonly
Returns the value of attribute session_value.
Instance Method Summary collapse
-
#initialize(value) ⇒ SqAuthSession
constructor
A new instance of SqAuthSession.
- #project_roles(project) ⇒ Object
- #role_exist?(roles, project, &block) ⇒ Boolean
Constructor Details
#initialize(value) ⇒ SqAuthSession
Returns a new instance of SqAuthSession.
4 5 6 7 |
# File 'lib/sq_auth/sq_auth_session.rb', line 4 def initialize value @cache = SqAuthCache.new @session_value = value end |
Instance Attribute Details
#session_value ⇒ Object (readonly)
Returns the value of attribute session_value.
3 4 5 |
# File 'lib/sq_auth/sq_auth_session.rb', line 3 def session_value @session_value end |
Instance Method Details
#project_roles(project) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sq_auth/sq_auth_session.rb', line 18 def project_roles project result = @cache.fetch(project) if result.nil? fetched_roles = yield(self, project) if fetched_roles @cache.save(project, fetched_roles) else return [] end else result end end |
#role_exist?(roles, project, &block) ⇒ Boolean
9 10 11 12 13 14 15 16 |
# File 'lib/sq_auth/sq_auth_session.rb', line 9 def role_exist? roles, project, &block result = @cache.fetch(project) if result.nil? yield(self, roles, project) else !([*roles] & result).empty? end end |