Module: ResourcePolicy

Defined in:
lib/resource_policy.rb,
lib/resource_policy/policy.rb,
lib/resource_policy/version.rb,
lib/resource_policy/protected_resource.rb,
lib/resource_policy/policy/actions_policy.rb,
lib/resource_policy/policy/merge_policies.rb,
lib/resource_policy/policy/attributes_policy.rb,
lib/resource_policy/policy/policy_configuration.rb,
lib/resource_policy/validators/action_validator.rb,
lib/resource_policy/validators/attributes_validator.rb,
lib/resource_policy/policy/action_policy_configuration.rb,
lib/resource_policy/policy/actions_policy/action_policy.rb,
lib/resource_policy/policy/attributes_policy/attribute_policy.rb,
lib/resource_policy/policy/actions_policy/actions_policy_model.rb,
lib/resource_policy/policy/attributes_policy/attribute_configuration.rb,
lib/resource_policy/policy/attributes_policy/attributes_policy_model.rb

Overview

Validates attributes hash.

Available options:

* `:apply_to` (required) - hash which needs to be validated using policy.
* `:allowed_to` (required) - access level which we need to check. In most cases it's `:read` or `:write`.

Usage example:

class MyClass
  include ActiveModel::Validations
  validates :some_policy, 'resource_policy/attributes': { apply_to: :some_params, allowed_to: :write }

  def some_policy
    SomePolicy.new
  end

  def some_params
    { foo: :foo, bar: :bar }
  end
end

Defined Under Namespace

Modules: Policy Classes: ActionValidator, AttributesValidator, Error, ProtectedResource

Constant Summary collapse

VERSION =
'1.1.0'