module IAmICan::Subject::RoleQuerying
Public Instance Methods
is!(role_name, with_tmp: true)
click to toggle source
# File lib/i_am_i_can/subject/role_querying.rb, line 22 def is! role_name, with_tmp: true raise VerificationFailed if isnt? role_name, with_tmp: with_tmp true end
is?(role_name, with_tmp: true)
click to toggle source
is_every!(*role_names, with_tmp: true)
click to toggle source
# File lib/i_am_i_can/subject/role_querying.rb, line 53 def is_every! *role_names, with_tmp: true raise VerificationFailed unless is_every?(*role_names, with_tmp: true) true end
Also aliased as: is_every_role_in!
is_every?(*role_names, with_tmp: true)
click to toggle source
# File lib/i_am_i_can/subject/role_querying.rb, line 45 def is_every? *role_names, with_tmp: true role_ids = i_am_i_can.role_model.where(name: role_names).ids return false if role_ids.size != role_names.size get_roles(with_tmp: with_tmp).where(id: role_ids).size == role_names.size end
Also aliased as: is_every_role_in?
is_in_one_of?(*group_names)
click to toggle source
# File lib/i_am_i_can/subject/role_querying.rb, line 69 def is_in_one_of? *group_names group_names.each { |name| return true if is_in_role_group? name } && false end
Also aliased as: in_one_of?
is_in_role_group?(name)
click to toggle source
Group Querying ===¶ ↑
# File lib/i_am_i_can/subject/role_querying.rb, line 62 def is_in_role_group? name group_members = i_am_i_can.role_group_model.find_by!(name: name)._roles.names (get_roles.names & group_members).present? end
Also aliased as: in_role_group?
is_one_of!(*role_names, with_tmp: true)
click to toggle source
# File lib/i_am_i_can/subject/role_querying.rb, line 38 def is_one_of! *role_names, with_tmp: true raise VerificationFailed unless is_one_of? *role_names, with_tmp: with_tmp true end
Also aliased as: is_one_of_roles!
is_one_of?(*role_names, with_tmp: true)
click to toggle source
# File lib/i_am_i_can/subject/role_querying.rb, line 30 def is_one_of? *role_names, with_tmp: true role_ids = i_am_i_can.role_model.where(name: role_names).ids return false if role_ids.blank? get_roles(with_tmp: with_tmp).exists?(id: role_ids) end
Also aliased as: is_one_of_roles?
isnt?(role_name, with_tmp: true)
click to toggle source
# File lib/i_am_i_can/subject/role_querying.rb, line 18 def isnt? role_name, with_tmp: true !is? role_name, with_tmp: with_tmp end