Module: Recurso::Identity

Defined in:
lib/recurso/concerns/identity.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
# File 'lib/recurso/concerns/identity.rb', line 3

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

Instance Method Details

#policy(resource = self) ⇒ Object



10
11
12
# File 'lib/recurso/concerns/identity.rb', line 10

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

#policy_classObject



23
24
25
# File 'lib/recurso/concerns/identity.rb', line 23

def policy_class
  Recurso::BasePolicy
end

#resources_with_permission(relation_name, action: :view, all_columns: true, include_actions: []) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/recurso/concerns/identity.rb', line 14

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