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
42 43 44 |
# File 'lib/trole_groups/storage/base_many.rb', line 42 def ds_field_name rolegroup_field end |
#ds_field_value ⇒ Object
the current value of the role field
48 49 50 51 |
# File 'lib/trole_groups/storage/base_many.rb', line 48 def ds_field_value # puts "#{rolegroup_subject}.#{ds_field_name}" if Troles::Common::Config.log_on? 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
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/trole_groups/storage/base_many.rb', line 55 def persist_role_changes! puts "TroleGroups::Storage::BaseMany.persist_role_changes!" if Troles::Common::Config.log_on? if !rolegroup_subject.respond_to? :save puts "could not save since no #save method on subject: #{rolegroup_subject}" if Troles::Common::Config.log_on? return false else puts "#{rolegroup_subject}.save" if Troles::Common::Config.log_on? rolegroup_subject.save rolegroup_subject.publish_change :role_groups end 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 35 36 37 38 |
# File 'lib/trole_groups/storage/base_many.rb', line 30 def set_ds_field value return if ds_field_value == value if Troles::Common::Config.log_on? puts "TroleGroups::Storage::BaseMany.set_ds_field:" puts "#{rolegroup_subject}.#{ds_field_name} = #{value}" end 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 |