{"id":29955046,"url":"https://github.com/foca/hal","last_synced_at":"2025-10-29T02:35:36.878Z","repository":{"id":958625,"uuid":"744824","full_name":"foca/hal","owner":"foca","description":"Simple authorization framework for ruby","archived":false,"fork":false,"pushed_at":"2010-06-28T19:11:09.000Z","size":96,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-04-10T10:19:51.094Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/foca.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-06-28T14:12:24.000Z","updated_at":"2014-05-01T16:43:18.000Z","dependencies_parsed_at":"2022-08-16T11:35:24.160Z","dependency_job_id":null,"html_url":"https://github.com/foca/hal","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/foca/hal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fhal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fhal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fhal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fhal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foca","download_url":"https://codeload.github.com/foca/hal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fhal/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268578914,"owners_count":24273089,"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","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-08-03T17:09:20.623Z","updated_at":"2025-10-19T16:14:20.230Z","avatar_url":"https://github.com/foca.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= HAL. Minimalist authorization framework for Ruby\n\nHAL is a class-based authorization framework for Ruby. It lets you define\nauthorization rules on classes, which will then be applied to all instances\nof said classes. For example:\n\n    class User \u003c Struct.new(:name); end\n    dave = User.new(\"Dave\")\n\n    HAL.rules_for User do\n      def open_the_pod_bay_doors?\n        subject.name != \"Dave\"\n      end\n    end\n\n    HAL.can(dave).open_the_pod_bay_doors? #=\u003e false\n\nWhen defining rules you can access a +subject+ method, which will reference\nwhatever object you pass to +can+.\n\nYou also have a more powerful version of \u003ctt\u003ecan\u003c/tt\u003e, called \u003ctt\u003ecan!\u003c/tt\u003e,\nwhich takes a block and will raise \u003ctt\u003eHAL::ICantLetYouDoThat\u003c/tt\u003e if the\nblock evaluates to false:\n\n    HAL.can!(dave) {|can| can.open_the_pod_bay_doors? } #=\u003e raises!\n\nFinally, you can include +HAL+ into your classes to get +can+ and\n\u003ctt\u003ecan!\u003c/tt\u003e as helper methods.\n\n    class UsersController \u003c ApplicationController\n      include HAL\n\n      before_filter :check_permissions, :only =\u003e [:edit, :update, :destroy]\n\n      def check_permissions\n        unless can(current_user).edit_user?(current_user)\n          redirect_to users_path, :alert =\u003e \"I can't let you do that, Dave\"\n        end\n      end\n    end\n\n== Installing\n\nAs a RubyGem\n\n    gem install hal\n\nFor rails 2.3, add to your config/environment.rb:\n\n    config.gem \"hal\", :lib =\u003e \"hal/rails\"\n\nFor rails 3, add to your Gemfile:\n\n    gem \"hal\", :require =\u003e \"hal/rails\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoca%2Fhal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoca%2Fhal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoca%2Fhal/lists"}