Class: CanTango::Filters::RoleFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/cantango/filters/role_filter.rb

Instance Attribute Summary

Attributes inherited from Filter

#include_list, #item

Instance Method Summary collapse

Methods inherited from Filter

#in_include_list?, #valid?

Constructor Details

#initialize(role, roles = nil) ⇒ RoleFilter

Returns a new instance of RoleFilter.



6
7
8
# File 'lib/cantango/filters/role_filter.rb', line 6

def initialize role, roles = nil
  super
end

Instance Method Details

#excluded?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/cantango/filters/role_filter.rb', line 14

def excluded?
  !excluded_roles.empty? && excluded_roles.include?(role)
end

#excluded_rolesObject



22
23
24
# File 'lib/cantango/filters/role_filter.rb', line 22

def excluded_roles
  CanTango.config.roles.excluded
end

#not_only?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/cantango/filters/role_filter.rb', line 10

def not_only?
  !only_roles.empty? && !only_roles.include?(role)
end

#only_rolesObject



18
19
20
# File 'lib/cantango/filters/role_filter.rb', line 18

def only_roles
  CanTango.config.roles.onlies
end