Sha256: c0251fb3f2286e5b2ba7806c53bfb4771d9f21be6feb21cd2e7216988be23aa9

Contents?: true

Size: 586 Bytes

Versions: 6

Compression:

Stored size: 586 Bytes

Contents

class Ability
  include CanCan::Ability

  def initialize(user)
    if user.is_admin == true
      can :destroy, String
    end

    if user.is_moderator == true
      can :update, String
    end

    can :read, String
  end
end

class AccessPolicy
  include AccessGranted::Policy

  def configure(user)
    role :administrator, { is_admin: true } do
      can :destroy, String
    end

    role :moderator, { is_moderator: true } do
      can :update, String
    end

    role :member do
      can :read, String
    end
  end
end

class User < Struct.new(:is_admin, :is_moderator)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
access-granted-1.0.4 benchmarks/config.rb
access-granted-1.0.3 benchmarks/config.rb
access-granted-1.0.2 benchmarks/config.rb
access-granted-1.0.1 benchmarks/config.rb
access-granted-0.2.1 benchmarks/config.rb
access-granted-0.2 benchmarks/config.rb