Sha256: b235db99aac192feadccc08012ee0aa6d2293466d1bdfdc4ac0b40b9e97e6f7d

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 Bytes

Contents

module Recurso
  module Identity
    def self.included(base)
      base.has_many :permissions,
        dependent: :destroy,
        class_name: Recurso::Config.instance.permission_class_name_for(base),
        foreign_key: Recurso::Config.instance.identity_foreign_key_for(base)
    end

    def policy(resource = self)
      (resource&.policy_class || Recurso::NilClassPolicy).new(self, resource)
    end

    def resources_with_permission(relation_name, action: :view, all_columns: true, include_actions: [])
      policy(Recurso::Global.instance).resources_with_permission(
        relation_name,
        action: action,
        all_columns: all_columns,
        include_actions: include_actions
      )
    end

    def policy_class
      Recurso::BasePolicy
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
recurso-0.6.1 lib/recurso/concerns/identity.rb