Class: Trole::Storage::RefOne
- Inherits:
-
BaseOne
- Object
- Troles::Common::Storage
- BaseOne
- Trole::Storage::RefOne
- Defined in:
- lib/trole/storage/ref_one.rb
Instance Attribute Summary
Attributes inherited from Troles::Common::Storage
Instance Method Summary collapse
-
#clear! ⇒ Object
Clears the role state of the role subject.
-
#display_roles ⇒ Array<Symbol>
display the role as a list of one symbol.
-
#ds_field_value? ⇒ Boolean
is it set?.
-
#initialize(role_subject) ⇒ RefOne
constructor
constructor.
-
#set_role(role) ⇒ Object
saves the role of the role subject in the data store.
Methods inherited from BaseOne
#find_role, #role_model, #role_to_embed, #set_default_role!, #set_roles
Methods inherited from Troles::Common::Storage
#ds_field_name, #ds_field_value, #name, #persist_role_changes!, #set_ds_field, #valid_roles
Constructor Details
#initialize(role_subject) ⇒ RefOne
constructor
11 12 13 |
# File 'lib/trole/storage/ref_one.rb', line 11 def initialize role_subject super end |
Instance Method Details
#clear! ⇒ Object
Clears the role state of the role subject
35 36 37 |
# File 'lib/trole/storage/ref_one.rb', line 35 def clear! set_ds_field nil end |
#display_roles ⇒ Array<Symbol>
display the role as a list of one symbol
17 18 19 20 |
# File 'lib/trole/storage/ref_one.rb', line 17 def display_roles return [] if !ds_field_value? [ds_field_value.name.to_sym] end |
#ds_field_value? ⇒ Boolean
is it set?
23 24 25 |
# File 'lib/trole/storage/ref_one.rb', line 23 def ds_field_value? ds_field_value end |
#set_role(role) ⇒ Object
saves the role of the role subject in the data store
29 30 31 32 |
# File 'lib/trole/storage/ref_one.rb', line 29 def set_role role role_to_set = role_model.where(:name => role).first set_ds_field role_to_set end |