Sha256: 080eb2b47aefbc4cc6aa4d5fd82de99ee91f6a25e062cd9cc71f870322ab86cc

Contents?: true

Size: 686 Bytes

Versions: 6

Compression:

Stored size: 686 Bytes

Contents

module RoleStrategy::Generic
  module RolesString    
    def self.default_role_attribute
      :roles_string
    end

    module Implementation           
      # assign roles
      def roles=(*roles)
        roles_str = roles.flatten.map{|r| r.to_s if valid_role?(r)}.compact.uniq.join(',')
        self.send("#{role_attribute}=", roles_str) if roles_str && roles_str.not.empty?
      end 
      alias_method :role=, :roles=

      # query assigned roles
      def roles
        self.send(role_attribute).split(',').uniq.map{|r| r.to_sym}
      end
      alias_method :roles_list, :roles
    end
    
    extend Roles::Generic::User::Configuration
    configure            
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
roles_generic-0.2.7 lib/roles_generic/strategy/multi/roles_string.rb
roles_generic-0.2.6 lib/roles_generic/strategy/multi/roles_string.rb
roles_generic-0.2.5 lib/roles_generic/strategy/multi/roles_string.rb
roles_generic-0.2.4 lib/roles_generic/strategy/multi/roles_string.rb
roles_generic-0.2.3 lib/roles_generic/strategy/multi/roles_string.rb
roles_generic-0.2.2 lib/roles_generic/strategy/multi/roles_string.rb