Class: Troles::Storage::BitMany
- Inherits:
-
BaseMany
- Object
- Common::Storage
- BaseMany
- Troles::Storage::BitMany
- Defined in:
- lib/troles/storage/bit_many.rb
Instance Attribute Summary
Attributes inherited from Common::Storage
Instance Method Summary collapse
-
#clear! ⇒ Object
Clears the role state of the role subject.
-
#display_roles ⇒ Array<Symbol>
display the roles as a list of symbols see Troles::Marshaller::Bitmask.
- #ds_field_value? ⇒ Boolean
-
#initialize(role_subject) ⇒ BitMany
constructor
constructor.
-
#set_default_role! ⇒ Object
Sets role to default state.
-
#set_roles(*roles) ⇒ Object
saves the roles for the role subject in the data store see Troles::Marshaller::Bitmask.
Methods inherited from Common::Storage
#ds_field_name, #ds_field_value, #name, #persist_role_changes!, #set_ds_field, #valid_roles
Constructor Details
#initialize(role_subject) ⇒ BitMany
constructor
11 12 13 |
# File 'lib/troles/storage/bit_many.rb', line 11 def initialize role_subject super end |
Instance Method Details
#clear! ⇒ Object
Clears the role state of the role subject
37 38 39 |
# File 'lib/troles/storage/bit_many.rb', line 37 def clear! set_ds_field 0 end |
#display_roles ⇒ Array<Symbol>
display the roles as a list of symbols see Troles::Marshaller::Bitmask
18 19 20 21 |
# File 'lib/troles/storage/bit_many.rb', line 18 def display_roles return [] if !ds_field_value? bitmask.read end |
#ds_field_value? ⇒ Boolean
23 24 25 |
# File 'lib/troles/storage/bit_many.rb', line 23 def ds_field_value? ds_field_value > 0 end |
#set_default_role! ⇒ Object
Sets role to default state
42 43 44 |
# File 'lib/troles/storage/bit_many.rb', line 42 def set_default_role! clear! end |
#set_roles(*roles) ⇒ Object
saves the roles for the role subject in the data store see Troles::Marshaller::Bitmask
30 31 32 33 34 |
# File 'lib/troles/storage/bit_many.rb', line 30 def set_roles *roles roles = roles.to_symbols_uniq return clear! if roles.empty? set_ds_field bitmask.write(roles.to_symbols) end |