Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using callable objects as scopes #261

Closed
palkan opened this issue May 4, 2024 · 1 comment
Closed

Allow using callable objects as scopes #261

palkan opened this issue May 4, 2024 · 1 comment
Labels
hackday RailsConf Hack Day challenges

Comments

@palkan
Copy link
Owner

palkan commented May 4, 2024

Context

Based on #192.

Let's make it possible using callable objects to extract scope implementations:

class ProjectPolicy < ApplicationPolicy
  relation_scope AuthorizedProjects

  # similar to
  relation_scope do |relation|
     AuthorizedProjects.call(relation)
  end
end

TODO

Let's update the .scope_for method to handle both blocks and callable objects, so, the new method definition would look like

def scope_for(type, name = :default, callable = nil, &block)
end
@palkan palkan added the hackday RailsConf Hack Day challenges label May 4, 2024
killondark added a commit to killondark/action_policy that referenced this issue May 7, 2024
@palkan
Copy link
Owner Author

palkan commented May 22, 2024

Closed by #263

@palkan palkan closed this as completed May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hackday RailsConf Hack Day challenges
Projects
None yet
Development

No branches or pull requests

1 participant