Sha256: 1bf6209609bea35e0cd7ac8dc4085d49af3e00462fb80c29e4b1377eab6909b4

Contents?: true

Size: 655 Bytes

Versions: 1

Compression:

Stored size: 655 Bytes

Contents

module Recurso
  class ResourcePolicy < BasePolicy
    def method_missing(method)
      action = method.to_s.sub('?', '').to_sym
      super unless Recurso::Config.instance.levels_for_action.keys.include?(action)

      Recurso::Queries::Single.new(identity, resource, action).permission?
    end

    def resources_with_permission(relation_name, action: :view, all_columns: true, include_actions: [:modify, :administer])
      Recurso::Queries::Relation.new(
        identity,
        resource,
        relation_name,
        all_columns: all_columns,
        action: action,
        include_actions: include_actions,
      ).resources
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
recurso-0.6.1 lib/recurso/policies/resource_policy.rb