Sha256: dd389b64dc6ff65d9c5c7022ee4fe0b319d9f10ba632849130735eb7d34b27fc

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

class AccessPolicy
  include AccessGranted::Policy

  def configure(user)
    # Example policy for AccessGranted.
    # For more details check the README at
    #
    # https://github.com/chaps-io/access-granted/blob/master/README.md
    #
    # Roles inherit from less important roles, so:
    # - :admin has permissions defined in :member, :guest and himself
    # - :member has permissions from :guest and himself
    # - :guest has only its own permissions since it's the first role.
    #
    # The most important role should be at the top.
    # In this case an administrator.
    #
    # role :admin, proc { |user| user.admin? } do
    #   can :destroy, User
    # end

    # More privileged role, applies to registered users.
    #
    # role :member, proc { |user| user.registered? } do
    #   can :create, Post
    #   can :create, Comment
    #   can [:update, :destroy], Post do |post|
    #     post.author == user
    #   end
    # end

    # The base role with no additional conditions.
    # Applies to every user.
    #
    # role :guest do
    #  can :read, Post
    #  can :read, Comment
    # end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
access-granted-1.0.3 lib/generators/templates/access_policy.rb
access-granted-1.0.2 lib/generators/templates/access_policy.rb
access-granted-1.0.1 lib/generators/templates/access_policy.rb