{"action":"created","issue":{"url":"https://api.github.com/repos/palkan/action_policy/issues/5","repository_url":"https://api.github.com/repos/palkan/action_policy","labels_url":"https://api.github.com/repos/palkan/action_policy/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/palkan/action_policy/issues/5/comments","events_url":"https://api.github.com/repos/palkan/action_policy/issues/5/events","html_url":"https://github.com/palkan/action_policy/issues/5","id":318885121,"node_id":"MDU6SXNzdWUzMTg4ODUxMjE=","number":5,"title":"Scope support","user":{"login":"palkan","id":1516722,"node_id":"MDQ6VXNlcjE1MTY3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/1516722?v=4","gravatar_id":"","url":"https://api.github.com/users/palkan","html_url":"https://github.com/palkan","followers_url":"https://api.github.com/users/palkan/followers","following_url":"https://api.github.com/users/palkan/following{/other_user}","gists_url":"https://api.github.com/users/palkan/gists{/gist_id}","starred_url":"https://api.github.com/users/palkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palkan/subscriptions","organizations_url":"https://api.github.com/users/palkan/orgs","repos_url":"https://api.github.com/users/palkan/repos","events_url":"https://api.github.com/users/palkan/events{/privacy}","received_events_url":"https://api.github.com/users/palkan/received_events","type":"User","site_admin":false},"labels":[{"id":908706616,"node_id":"MDU6TGFiZWw5MDg3MDY2MTY=","url":"https://api.github.com/repos/palkan/action_policy/labels/discussion","name":"discussion","color":"8f48d6","default":false},{"id":883897354,"node_id":"MDU6TGFiZWw4ODM4OTczNTQ=","url":"https://api.github.com/repos/palkan/action_policy/labels/enhancement","name":"enhancement","color":"a2eeef","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/palkan/action_policy/milestones/2","html_url":"https://github.com/palkan/action_policy/milestone/2","labels_url":"https://api.github.com/repos/palkan/action_policy/milestones/2/labels","id":3429396,"node_id":"MDk6TWlsZXN0b25lMzQyOTM5Ng==","number":2,"title":"0.3.0","description":"Scopes & strong params support, instrumentation, i18n integration.","creator":{"login":"palkan","id":1516722,"node_id":"MDQ6VXNlcjE1MTY3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/1516722?v=4","gravatar_id":"","url":"https://api.github.com/users/palkan","html_url":"https://github.com/palkan","followers_url":"https://api.github.com/users/palkan/followers","following_url":"https://api.github.com/users/palkan/following{/other_user}","gists_url":"https://api.github.com/users/palkan/gists{/gist_id}","starred_url":"https://api.github.com/users/palkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palkan/subscriptions","organizations_url":"https://api.github.com/users/palkan/orgs","repos_url":"https://api.github.com/users/palkan/repos","events_url":"https://api.github.com/users/palkan/events{/privacy}","received_events_url":"https://api.github.com/users/palkan/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":3,"state":"open","created_at":"2018-06-16T18:47:02Z","updated_at":"2018-09-18T23:44:22Z","due_on":"2018-07-15T07:00:00Z","closed_at":null},"comments":9,"created_at":"2018-04-30T13:13:08Z","updated_at":"2018-09-18T23:46:37Z","closed_at":"2018-09-18T23:44:22Z","author_association":"OWNER","body":"Provide ability to scope relations (e.g. ActiveRecord).\r\n\r\n## Defining scopes\r\n\r\n```ruby\r\nclass UserPolicy < ApplicationPolicy\r\n   # use DSL for defining scopes\r\n   # default scope\r\n   scope do\r\n     # this block is executed within a policy object,\r\n     # so all the methods are available (e.g. authorization contexts)\r\n     # `relation` is a passed to a helper object\r\n     relation.joins(:accesses).where(accesses: { user_id: user.id })\r\n   end\r\n\r\n   # named scop\r\n   scope :own do\r\n     relation.where(user_id: user.id)\r\n   end\r\nend\r\n```\r\n\r\n## Applying scopes\r\n\r\n```ruby\r\ndef index\r\n  @posts = scoped(Post.all)\r\n   \r\n  # or\r\n  \r\n  @posts = scoped(Post.all, :own)\r\nend\r\n```\r\n\r\n\r\n## To discuss\r\n\r\n- Is `relation` a good name for a passed scope within a policy?\r\n\r\n- Is `scoped` a good name for a helper? I don't like Pundit's `policy_scope`, it's too verbose and doesn't sound like English, IMO.\r\n"},"comment":{"url":"https://api.github.com/repos/palkan/action_policy/issues/comments/422596153","html_url":"https://github.com/palkan/action_policy/issues/5#issuecomment-422596153","issue_url":"https://api.github.com/repos/palkan/action_policy/issues/5","id":422596153,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMjU5NjE1Mw==","user":{"login":"palkan","id":1516722,"node_id":"MDQ6VXNlcjE1MTY3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/1516722?v=4","gravatar_id":"","url":"https://api.github.com/users/palkan","html_url":"https://github.com/palkan","followers_url":"https://api.github.com/users/palkan/followers","following_url":"https://api.github.com/users/palkan/following{/other_user}","gists_url":"https://api.github.com/users/palkan/gists{/gist_id}","starred_url":"https://api.github.com/users/palkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palkan/subscriptions","organizations_url":"https://api.github.com/users/palkan/orgs","repos_url":"https://api.github.com/users/palkan/repos","events_url":"https://api.github.com/users/palkan/events{/privacy}","received_events_url":"https://api.github.com/users/palkan/received_events","type":"User","site_admin":false},"created_at":"2018-09-18T23:46:37Z","updated_at":"2018-09-18T23:46:37Z","author_association":"OWNER","body":"Hey, everyone!\r\n\r\nLooks like Scoping API is almost there (I've just merged https://github.com/palkan/action_policy/pull/33).\r\n\r\nCheck out the docs: [behaviour](https://github.com/palkan/action_policy/blob/master/docs/behaviour.md), [scoping](https://github.com/palkan/action_policy/blob/master/docs/scoping.md).\r\n\r\nI plan to release it a little bit later along with other smaller features for [0.3.0](https://github.com/palkan/action_policy/milestone/2) and after trying to play with it in production.\r\nYou can give `master` a try too)\r\n"}}
{"actor":{"display_login":"palkan"}}