Class: Haconiwa::Capabilities
- Inherits:
-
Object
- Object
- Haconiwa::Capabilities
- Defined in:
- lib/haconiwa/capabilities.rb
Instance Method Summary collapse
- #allow(*keys) ⇒ Object
- #apply! ⇒ Object
- #drop(*keys) ⇒ Object
-
#initialize ⇒ Capabilities
constructor
A new instance of Capabilities.
Constructor Details
#initialize ⇒ Capabilities
Returns a new instance of Capabilities.
5 6 7 8 |
# File 'lib/haconiwa/capabilities.rb', line 5 def initialize @blacklist = [] @whitelist = [] end |
Instance Method Details
#allow(*keys) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/haconiwa/capabilities.rb', line 10 def allow(*keys) if keys.first == :all @whitelist.clear else @whitelist.concat(keys) end end |
#apply! ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/haconiwa/capabilities.rb', line 22 def apply! if acts_as_whitelist? SmallLibcap.apply_cap_whitelist(list: @whitelist.uniq) else @blacklist.uniq.each do |n| SmallLibcap.drop_cap_by_name(n) end end end |
#drop(*keys) ⇒ Object
18 19 20 |
# File 'lib/haconiwa/capabilities.rb', line 18 def drop(*keys) @blacklist.concat(keys) end |