Sha256: 3e23030eca41db18e812a2c52e31c9dce018c9fbc1a8e3828c5046c225f09871

Contents?: true

Size: 685 Bytes

Versions: 3

Compression:

Stored size: 685 Bytes

Contents

class Ability
  include CanCanNamespace::Ability
  
  attr_accessor :context, :user

  def initialize(user, context = nil)
    alias_action :delete, :to => :destroy

    @user = (user || User.new) # guest user (not logged in)
    @context = context
    
    case @user.role_type_id
      when RoleType.default.id then default
      when RoleType.redactor.id then redactor
      when RoleType.moderator.id then moderator
      when RoleType.admin.id then admin
    end
  end
  
  def default
    # TODO
  end
  
  def redactor
    # TODO
  end
  
  def moderator
    # TODO
  end
  
  def admin
    can :manage, :all
    can :manage, :all, :context => :manage
    
    # TODO
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sunrise-core-0.1.2 lib/generators/sunrise/templates/models/defaults/ability.rb
sunrise-core-0.1.1 lib/generators/sunrise/templates/models/defaults/ability.rb
sunrise-core-0.1.0 lib/generators/sunrise/templates/models/defaults/ability.rb