Module: ResourcePolicy::Policy::ActionsPolicy
- Defined in:
- lib/resource_policy/policy/actions_policy.rb,
lib/resource_policy/policy/actions_policy/action_policy.rb,
lib/resource_policy/policy/actions_policy/actions_policy_model.rb
Overview
Allows to define actions policy using configuration block.
Usage example:
class SomeModelPolicy
include Policy::ActionsPolicy
policy do |c|
c.action(:create).allowed(if: :current_user_is_admin?)
end
private
def current_user_is_admin?
current_user.admin?
end
...
end
Defined Under Namespace
Classes: ActionPolicy, ActionsPolicyModel
Instance Method Summary collapse
Instance Method Details
#action(name) ⇒ Object
30 31 32 |
# File 'lib/resource_policy/policy/actions_policy.rb', line 30 def action(name) actions_policy.public_send(name) if actions_policy.respond_to?(name) end |
#actions_policy ⇒ Object
26 27 28 |
# File 'lib/resource_policy/policy/actions_policy.rb', line 26 def actions_policy @actions_policy ||= ActionsPolicyModel.new(self) end |