{"id":20206274,"url":"https://github.com/sleede/papeel","last_synced_at":"2026-05-12T06:36:02.530Z","repository":{"id":56887362,"uuid":"70604218","full_name":"sleede/papeel","owner":"sleede","description":"Roles library for rails projects","archived":false,"fork":false,"pushed_at":"2016-10-13T14:47:34.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-13T23:18:28.890Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sleede.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-11T14:52:54.000Z","updated_at":"2016-10-11T14:53:32.000Z","dependencies_parsed_at":"2022-08-21T00:20:59.591Z","dependency_job_id":null,"html_url":"https://github.com/sleede/papeel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sleede%2Fpapeel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sleede%2Fpapeel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sleede%2Fpapeel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sleede%2Fpapeel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sleede","download_url":"https://codeload.github.com/sleede/papeel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241644542,"owners_count":19996177,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T05:22:40.282Z","updated_at":"2026-05-12T06:35:57.484Z","avatar_url":"https://github.com/sleede.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Papeel\n\n## Setup\n\n```bash\nrails generate papeel:initializer\nrails generate papeel:migration\nrake db:migrate\n```\n\nIn `config/initializer/papeel.rb`, whitelist your roles (needed to validate a role):\n```ruby\nPapeel.configure do |config|\n  config.roles = [:super_admin, :admin]\nend\n```\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  include Papeel::ActsAsPapeelUser\n  acts_as_papeel_user\nend\n```\n\n```ruby\nclass Forum \u003c ActiveRecord::Base\n  include Papeel::ActsAsPapeelResource\n  acts_as_papeel_resource\nend\n```\n\n## What it does ?\n\n### acts_as_papeel_user\n\n#### instance methods\n\nIt adds a relation `has_many :roles` to the User class.\n\nIt adds a method named `has_role?` which work as follow:\n```ruby\nuser = User.find(1)\nPapeel::Role.create user: user, name: :admin\nuser.has_role? :admin\n=\u003e true\n\nuser.has_role? :admin, any: true\n=\u003e false\n\n# =======================================\nuser = User.find(2)\nforum = Forum.find(1)\nPapeel::Role.create user: user, name: :admin, resource: forum\nuser.has_role? :admin\n=\u003e false\n\nuser.has_role? :admin, any: true\n=\u003e true\n\nuser.has_role? :admin, on: forum\n=\u003e true\n\nuser.has_role? :admin, on_type: \"Forum\"\n=\u003e true\n\nuser.has_role? :admin, on_type: \"Forum\", on_id: forum.id\n=\u003e true\n```\n\nit generates methods based on roles specified in papeel configuration, example:\n\n```ruby\n# config/initialize\nPapeel.configure do |config|\n  config.roles = [:super_admin, :admin]\nend\n\n# generates the following methods\nuser = User.find(1)\nforum = Forum.find(1)\n\nuser.is_super_admin?\nuser.is_admin?\nuser.is_admin? on: forum\n```\n\nThose methods accept the same arguments as the `has_role?` method.\n\n#### class methods\n\nit adds scopes based on papeel configuration, example:\n\n```ruby\nUser.super_admin \n# return users who are super_admin with AND without resource,\n# chain a where clause if you want to be more specific\n\nUser.admin\n# same but for admin role\n```\n\n### acts_as_papeel_resource\n\n#### instance methods\n\nIt adds a *polymorphic* relation `has_many :roles_as_resource` to the resource class.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsleede%2Fpapeel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsleede%2Fpapeel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsleede%2Fpapeel/lists"}