Class: Formol::Permissions::Profiles
- Inherits:
-
Object
- Object
- Formol::Permissions::Profiles
- Defined in:
- lib/formol/permissions/profiles.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](name) ⇒ Object
- #add_profile(name, opts = {}) ⇒ Object
- #add_right_to_profile(name, right) ⇒ Object
- #delete_right_from_profile(name, right) ⇒ Object
-
#initialize ⇒ Profiles
constructor
A new instance of Profiles.
- #profiles ⇒ Object
Constructor Details
#initialize ⇒ Profiles
Returns a new instance of Profiles.
4 5 6 |
# File 'lib/formol/permissions/profiles.rb', line 4 def initialize @profiles = {} end |
Class Method Details
Instance Method Details
#[](name) ⇒ Object
39 40 41 |
# File 'lib/formol/permissions/profiles.rb', line 39 def [](name) @profiles[name.to_sym] end |
#add_profile(name, opts = {}) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/formol/permissions/profiles.rb', line 30 def add_profile(name, opts = {}) r = [] r += self[opts[:extends]].rights if opts[:extends] r += opts[:rights] if opts[:rights] @profiles[name.to_sym] = Profile.new(name, r.uniq) end |
#add_right_to_profile(name, right) ⇒ Object
18 19 20 |
# File 'lib/formol/permissions/profiles.rb', line 18 def add_right_to_profile(name, right) @profiles[name.to_sym] << right.to_sym end |
#delete_right_from_profile(name, right) ⇒ Object
22 23 24 |
# File 'lib/formol/permissions/profiles.rb', line 22 def delete_right_from_profile(name, right) @profiles[name.to_sym].delete(right) end |
#profiles ⇒ Object
26 27 28 |
# File 'lib/formol/permissions/profiles.rb', line 26 def profiles @profiles.keys end |