Sha256: 80e5d81581da5d51887967d0b4f06d8c02b161db11e6df490599547d0e2dde9a

Contents?: true

Size: 929 Bytes

Versions: 10

Compression:

Stored size: 929 Bytes

Contents

class Ability
  include CanCan::Ability



  def initialize(user)
    if user

      # Owners can do everything

      if user.owner?
        can :manage, :all
        return
      end

      # Admins can create teams

      if user.admin?
        can [:read, :create], Team
      end

      # If you're logged in, you can see teams

      can :read, :teams

      # Users get abilities based on their role
      # in any teams they are members of

      user.roles.each do |role|
        Houston.config.configure_team_abilities(self, role)
      end
    end

    if Houston.config.defines_abilities?
      Houston.config.configure_abilities(self, user)
    else
      default_abilities_for(user)
    end
  end



  def default_abilities_for(user)
    return unless user

    # If you're logged in, you can see everything
    can :read, :all

    # If you're logged in, you can update yourself
    can :update, user
  end



end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
houston-core-0.9.2 app/models/ability.rb
houston-core-0.9.1 app/models/ability.rb
houston-core-0.9.0 app/models/ability.rb
houston-core-0.9.0.rc1 app/models/ability.rb
houston-core-0.8.4 app/models/ability.rb
houston-core-0.8.3 app/models/ability.rb
houston-core-0.8.2 app/models/ability.rb
houston-core-0.8.1 app/models/ability.rb
houston-core-0.8.0 app/models/ability.rb
houston-core-0.8.0.pre2 app/models/ability.rb