Sha256: 516ea0eaa4a07674e9e4470717416a7dfe8b5c808d4c52272db478301ded0a2a

Contents?: true

Size: 861 Bytes

Versions: 5

Compression:

Stored size: 861 Bytes

Contents

#
# @author Kristian Mandrup
#
# Sngle role storage that stores a role as a Role instance reference
#
module Trole::Storage
  class RefOne < BaseOne        

    # constructor
    # @param [Symbol] the role subject
    def initialize role_subject
      super
    end

    # display the role as a list of one symbol
    # @return [Array<Symbol>] roles list
    def display_roles 
      return [] if !ds_field_value?
      [ds_field_value.name.to_sym]
    end    

    # is it set?
    def ds_field_value?
      ds_field_value
    end      

    # saves the role of the role subject in the data store
    # @param [Symbol] the role name
    def set_role role
      role_to_set = role_model.where(:name => role).first
      set_ds_field role_to_set
    end  

    # Clears the role state of the role subject 
    def clear!
      set_ds_field nil
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
troles-0.6.1 lib/trole/storage/ref_one.rb
troles-0.6.0 lib/trole/storage/ref_one.rb
troles-0.5.2 lib/trole/storage/ref_one.rb
troles-0.5.1 lib/trole/storage/ref_one.rb
troles-0.5.0 lib/trole/storage/ref_one.rb