Module: Authz::Models::Rolable

Extended by:
ActiveSupport::Concern
Defined in:
lib/authz/models/rolable.rb

Overview

Must be included in the host application’s class in charge of users.

Instance Method Summary collapse

Instance Method Details

#authz_labelString

Returns Label used to label each rolable instance in the context of Authz.

Returns:

  • (String)

    Label used to label each rolable instance in the context of Authz



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/authz/models/rolable.rb', line 47

def authz_label
  if respond_to? :name
    name
  elsif respond_to? :email
    email
  elsif respond_to? :id
    "#{self.to_s}##{id}"
  else
    to_s
  end
end

#roles_cache_keyString

Returns a composite cache key using the keys of the granted roles. The key will be modified when the configuration of any of the granted roles changes.

Returns:

  • (String)

    a composite cache key using the keys of the granted roles. The key will be modified when the configuration of any of the granted roles changes.



62
63
64
# File 'lib/authz/models/rolable.rb', line 62

def roles_cache_key
  roles.map(&:cache_key).join('/')
end