Sha256: 28aa09bf90a5709c1adc948c708b82257ff0a8fc03d0dfc063b0fc3b62f7dfbb

Contents?: true

Size: 930 Bytes

Versions: 15

Compression:

Stored size: 930 Bytes

Contents

module Roles::Generic::User 
  module Configuration
    def configure(options={})
      numericality = options[:num]
      type = options[:type]
      
      class_eval do
        include Roles::Generic::User
        include Roles::Generic::User::SingleRole if numericality == :single
        if type == :role_class
          include Roles::Generic::Role::InstanceMethods           
        end
        
        include self::Implementation
        
        alias_method :role_symbols, :roles
      end
      extend Roles::Generic::User::ClassMethods
      extend Roles::Generic::User::DefaultRoleKeys
    end
  end
  
  module SingleRole
    def role
      roles.first
    end

    def role= new_role
      self.roles = new_role
    end
  end
  
  module DefaultRoleKeys
    def default_role_key
      valid_roles.last || :user
    end

    def admin_role_key
      valid_roles.first || :admin      
    end            
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
roles_generic-0.5.0 lib/roles_generic/generic/user/configuration.rb
roles_generic-0.3.9 lib/roles_generic/generic/user/configuration.rb
roles_generic-0.3.8 lib/roles_generic/generic/user/configuration.rb
roles_generic-0.3.7.2 lib/roles_generic/generic/user/configuration.rb
roles_generic-0.3.7.1 lib/roles_generic/generic/user/configuration.rb
roles_generic-0.3.7 lib/roles_generic/generic/user/configuration.rb
roles_generic-0.3.6 lib/roles_generic/generic/user/configuration.rb
roles_generic-0.3.5 lib/roles_generic/generic/user/configuration.rb
roles_generic-0.3.4 lib/roles_generic/generic/user/configuration.rb
roles_generic-0.3.3 lib/roles_generic/generic/user/configuration.rb
roles_generic-0.2.7 lib/roles_generic/generic/user/configuration.rb
roles_generic-0.2.6 lib/roles_generic/generic/user/configuration.rb
roles_generic-0.2.5 lib/roles_generic/generic/user/configuration.rb
roles_generic-0.2.4 lib/roles_generic/generic/user/configuration.rb
roles_generic-0.2.3 lib/roles_generic/generic/user/configuration.rb