Sha256: 7f37c3b9bf0abdd45fc540bf80dd83165cd4825247ac19d6a44df27b48937385
Contents?: true
Size: 958 Bytes
Versions: 5
Compression:
Stored size: 958 Bytes
Contents
module RoleStrategy::Generic module OneRole def self.default_role_attribute :one_role end module Implementation # assign roles def roles=(*roles) raise "Role class #{role_class} does not have a #find_role(role) method" if !role_class.respond_to? :find_role first_role = roles.flatten.first role_relation = role_class.find_role(first_role) if role_relation && role_relation.kind_of?(role_class) self.send("#{role_attribute}=", role_relation) end end # query assigned roles def roles [self.send(role_attribute).name.to_sym] end def roles_list self.roles.to_a end end extend Roles::Generic::User::Configuration configure :num => :single, :type => :role_class def self.included(base) base.extend Roles::Generic::Role::ClassMethods end end end
Version data entries
5 entries across 5 versions & 1 rubygems