Class: TroleGroups::Storage::BaseMany
- Inherits:
-
Troles::Common::Storage
- Object
- Troles::Common::Storage
- TroleGroups::Storage::BaseMany
- Defined in:
- lib/trole_groups/storage.rb,
lib/trole_groups/storage/base_many.rb
Overview
autoload :StringMany, ‘trole_groups/storage/string_many’
Instance Attribute Summary collapse
-
#rolegroup_subject ⇒ Object
readonly
Returns the value of attribute rolegroup_subject.
Attributes inherited from Troles::Common::Storage
Instance Method Summary collapse
-
#ds_field_name ⇒ Symbol
the name of the role field.
-
#ds_field_value ⇒ Object
the current value of the role field.
-
#initialize(rolegroup_subject) ⇒ BaseMany
constructor
initializes storage with reference to role subject.
-
#name ⇒ Symbol
name/type of storage.
-
#persist_role_changes! ⇒ true, ...
Attempts to persist the role field changes.
-
#set_ds_field(value) ⇒ Object
sets the value of the role field (@trole or @troles) and persists the value (in the data store).
-
#valid_roles ⇒ Array<Symbol>
valid roles of the role subjects class (fx account - i.e the account rules!).
Constructor Details
#initialize(rolegroup_subject) ⇒ BaseMany
initializes storage with reference to role subject
12 13 14 |
# File 'lib/trole_groups/storage/base_many.rb', line 12 def initialize rolegroup_subject @rolegroup_subject = rolegroup_subject end |
Instance Attribute Details
#rolegroup_subject ⇒ Object (readonly)
Returns the value of attribute rolegroup_subject.
8 9 10 |
# File 'lib/trole_groups/storage/base_many.rb', line 8 def rolegroup_subject @rolegroup_subject end |
Instance Method Details
#ds_field_name ⇒ Symbol
the name of the role field
38 39 40 |
# File 'lib/trole_groups/storage/base_many.rb', line 38 def ds_field_name rolegroup_field end |
#ds_field_value ⇒ Object
the current value of the role field
44 45 46 |
# File 'lib/trole_groups/storage/base_many.rb', line 44 def ds_field_value rolegroup_subject.send(ds_field_name) end |
#name ⇒ Symbol
name/type of storage
24 25 26 |
# File 'lib/trole_groups/storage/base_many.rb', line 24 def name :generic end |
#persist_role_changes! ⇒ true, ...
Attempts to persist the role field changes
50 51 52 53 54 |
# File 'lib/trole_groups/storage/base_many.rb', line 50 def persist_role_changes! return false if !rolegroup_subject.respond_to? :save! rolegroup_subject.save! rolegroup_subject.publish_change :role_groups end |
#set_ds_field(value) ⇒ Object
sets the value of the role field (@trole or @troles) and persists the value (in the data store)
30 31 32 33 34 |
# File 'lib/trole_groups/storage/base_many.rb', line 30 def set_ds_field value return if ds_field_value == value rolegroup_subject.send(:"#{ds_field_name}=", value) persist_role_changes! end |
#valid_roles ⇒ Array<Symbol>
valid roles of the role subjects class (fx account - i.e the account rules!)
18 19 20 |
# File 'lib/trole_groups/storage/base_many.rb', line 18 def valid_roles rolegroup_subject.class.valid_roles end |