Sha256: 5158508c87f6b8736c8a33d0a3c672c415583c369da443377689192630b0d666

Contents?: true

Size: 797 Bytes

Versions: 7

Compression:

Stored size: 797 Bytes

Contents

class Ability
  include CanCan::Ability

  def initialize(user)
    if user.is_admin
      can :destroy, String
      can :foo, Integer
    end

    if user.is_moderator
      can :update, String
      can :bar, String
    end

    can :read, String
    can :zoom, Integer
    can :boom, Hash
    can :rub, Fixnum
  end
end

class AccessPolicy
  include AccessGranted::Policy

  def configure
    role :administrator, { is_admin: true } do
      can :destroy, String
      can :foo, Integer
    end

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

    role :member do
      can :read, String
      can :zoom, Integer
      can :boom, Hash
      can :rub, Fixnum
    end
  end
end

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
access-granted-1.3.3 benchmarks/config.rb
access-granted-1.3.1 benchmarks/config.rb
access-granted-1.3.0 benchmarks/config.rb
access-granted-1.2.0 benchmarks/config.rb
access-granted-1.1.2 benchmarks/config.rb
access-granted-1.1.1 benchmarks/config.rb
access-granted-1.1.0 benchmarks/config.rb