class Troles::Common::Storage
Attributes
role_subject[R]
Public Class Methods
new(role_subject)
click to toggle source
initializes storage with reference to role subject @param [Object] the role subject (fx a User or UserAccount)
# File lib/troles/common/storage.rb, line 12 def initialize role_subject @role_subject = role_subject end
Public Instance Methods
ds_field_name()
click to toggle source
the name of the role field @return [Symbol] the name
# File lib/troles/common/storage.rb, line 44 def ds_field_name role_field end
ds_field_value()
click to toggle source
the current value of the role field @return [Object] the value
# File lib/troles/common/storage.rb, line 50 def ds_field_value role_subject.send(ds_field_name) end
name()
click to toggle source
name/type of storage @return [Symbol]
# File lib/troles/common/storage.rb, line 24 def name :generic end
persist_role_changes!()
click to toggle source
Attempts to persist the role field changes @return [true, false, error] true if saved, false if no save! method, Error on some error
# 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)
click to toggle source
sets the value of the role field (@trole or @troles) and persists the value (in the data store) @param [Object] the value to set on the role field of the role subject
# 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()
click to toggle source
valid roles of the role subjects class (fx account - i.e the account rules!) @return [Array<Symbol>] the list of valid roles
# File lib/troles/common/storage.rb, line 18 def valid_roles role_subject.class.valid_roles end
Protected Instance Methods
role_field()
click to toggle source
# File lib/troles/common/storage.rb, line 74 def role_field troles_config.role_field end
role_list()
click to toggle source
# File lib/troles/common/storage.rb, line 82 def role_list role_subject.role_list end
role_model()
click to toggle source
# File lib/troles/common/storage.rb, line 78 def role_model troles_config.role_model end
troles_config()
click to toggle source
# File lib/troles/common/storage.rb, line 70 def troles_config role_subject.class.troles_config end