Class: Menilite::PrivilegeService
- Inherits:
-
Object
- Object
- Menilite::PrivilegeService
- Defined in:
- lib/menilite/server/privilege.rb
Instance Attribute Summary collapse
-
#privileges ⇒ Object
readonly
Returns the value of attribute privileges.
Class Method Summary collapse
Instance Method Summary collapse
- #get_privileges(names) ⇒ Object
-
#initialize ⇒ PrivilegeService
constructor
A new instance of PrivilegeService.
Constructor Details
#initialize ⇒ PrivilegeService
Returns a new instance of PrivilegeService.
19 20 21 |
# File 'lib/menilite/server/privilege.rb', line 19 def initialize @privileges = [] end |
Instance Attribute Details
#privileges ⇒ Object (readonly)
Returns the value of attribute privileges.
17 18 19 |
# File 'lib/menilite/server/privilege.rb', line 17 def privileges @privileges end |
Class Method Details
.current ⇒ Object
29 30 31 32 |
# File 'lib/menilite/server/privilege.rb', line 29 def self.current return nil if @disable Thread.current.thread_variable_get(:previlege_service) end |
.disable(&block) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/menilite/server/privilege.rb', line 34 def self.disable(&block) @disable = true block.call ensure @disable = false end |
.init ⇒ Object
23 24 25 26 27 |
# File 'lib/menilite/server/privilege.rb', line 23 def self.init instance = PrivilegeService.new Thread.current.thread_variable_set(:previlege_service, instance) @disable = false end |
Instance Method Details
#get_privileges(names) ⇒ Object
41 42 43 |
# File 'lib/menilite/server/privilege.rb', line 41 def get_privileges(names) names.map{|key| @privileges.find{|p| p.key == key } }.compact end |