Class: Troles::Common::Storage
Direct Known Subclasses
Trole::Storage::BaseOne, TroleGroups::Storage::BaseMany, Storage::BaseMany
Instance Attribute Summary collapse
-
#role_subject ⇒ Object
readonly
Returns the value of attribute role_subject.
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(role_subject) ⇒ Storage
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(role_subject) ⇒ Storage
initializes storage with reference to role subject
12 13 14 |
# File 'lib/troles/common/storage.rb', line 12 def initialize role_subject @role_subject = role_subject end |
Instance Attribute Details
#role_subject ⇒ Object (readonly)
Returns the value of attribute role_subject.
8 9 10 |
# File 'lib/troles/common/storage.rb', line 8 def role_subject @role_subject end |
Instance Method Details
#ds_field_name ⇒ Symbol
the name of the role field
44 45 46 |
# File 'lib/troles/common/storage.rb', line 44 def ds_field_name role_field end |
#ds_field_value ⇒ Object
the current value of the role field
50 51 52 |
# File 'lib/troles/common/storage.rb', line 50 def ds_field_value role_subject.send(ds_field_name) end |
#name ⇒ Symbol
name/type of storage
24 25 26 |
# File 'lib/troles/common/storage.rb', line 24 def name :generic end |
#persist_role_changes! ⇒ true, ...
Attempts to persist the role field changes
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/troles/common/storage.rb', line 56 def persist_role_changes! puts "Troles::Common::Storage::BaseMany.persist_role_changes!" if Troles::Common::Config.log_on? if !role_subject.respond_to? :save puts "could not save since no #save method on subject: #{role_subject}" if Troles::Common::Config.log_on? return false else puts "#{role_subject}.save" if Troles::Common::Config.log_on? role_subject.save role_subject.publish_change :roles 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 39 40 |
# File 'lib/troles/common/storage.rb', line 30 def set_ds_field value return if ds_field_value == value if Troles::Common::Config.log_on? puts "Troles::Common::Storage.set_ds_field:" puts "#{rolegroup_subject}.#{ds_field_name} = #{value}" end role_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/troles/common/storage.rb', line 18 def valid_roles role_subject.class.valid_roles end |