lucky_can
Version, currently master branch1 version
- master branchlatestMar 24, 2020
github.com/confact/lucky_can
A simple pundit policies library for Lucky Framework in Crystal
Installation
# Add this to your shard.yml
dependencies:
lucky_can:
github: confact/lucky_can
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
0.33.0- License
- MIT
- Author
- Håkan Nylén
Dependencies
This version declares no dependencies.
README
lucky_can
An little nicer way to handle authorization rules for your lucky app
Installation
-
Add the dependency to your
shard.yml:dependencies: lucky_can: github: confact/lucky_can -
Run
shards install
Usage
-
require "lucky_can" -
create an
policiesdirectory where all your policies will be. Now you will Add an require for that directory to the app.cr file beforepagesrequire. Add this:require "./policies/**" -
now you can create your policies in
policiesdirectory.
Simple usage
class TeamPolicy < LuckyCan::BasePolicy
can show, team, current_user do
return false if current_user.nil?
team.users.include?(current_user)
end
end
this generate following methods for you to use by an macro:
TeamPolicy.show?(team, current_user)- for simple bool check if the user have access to the team.TeamPolicy.show_not_found?(team, current_user, context)- Return an Lucky::RouteNotFoundError if the code in the block return false.TeamPolicy.show_forbidden?(team, current_user, context)- Return an LuckyCan::ForbiddenError if the code in the block return false.
Contributing
- Fork it (https://github.com/confact/lucky_can/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Håkan Nylén - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Mar 24, 2020
- Crystal
0.33.0- Indexed
- yes
Dependents
Repository
github.com/confact/lucky_can
Metadata
- Created
- Aug 12, 2026
- Updated
- Oct 19, 2026
- Synced
- Oct 19, 2026
- Versions
- 1