Module: IAmICan::Subject::RoleQuerying
- Defined in:
- lib/i_am_i_can/subject/role_querying.rb
Instance Method Summary collapse
- #is!(role) ⇒ Object (also: #is_role!, #has_role!)
-
#is?(role) ⇒ Boolean
(also: #is_role?, #has_role?)
Role Querying ===.
- #is_every!(*roles) ⇒ Object (also: #is_every_role_in!)
- #is_every?(*roles) ⇒ Boolean (also: #is_every_role_in?)
- #is_in_one_of?(*group_names) ⇒ Boolean (also: #in_one_of?)
-
#is_in_role_group?(name) ⇒ Boolean
(also: #in_role_group?)
Group Querying ===.
- #is_one_of!(*roles) ⇒ Object (also: #is_one_of_roles!)
- #is_one_of?(*roles) ⇒ Boolean (also: #is_one_of_roles?)
- #isnt?(role) ⇒ Boolean
Instance Method Details
#is!(role) ⇒ Object Also known as: is_role!, has_role!
18 19 20 21 |
# File 'lib/i_am_i_can/subject/role_querying.rb', line 18 def is! role raise VerificationFailed if isnt? role true end |
#is?(role) ⇒ Boolean Also known as: is_role?, has_role?
Role Querying ===
7 8 9 |
# File 'lib/i_am_i_can/subject/role_querying.rb', line 7 def is? role role.to_sym.in?(local_role_names) || role.to_sym.in?(stored_role_names) end |
#is_every!(*roles) ⇒ Object Also known as: is_every_role_in!
44 45 46 |
# File 'lib/i_am_i_can/subject/role_querying.rb', line 44 def is_every! *roles roles.each { |role| is! role } && true end |
#is_every?(*roles) ⇒ Boolean Also known as: is_every_role_in?
38 39 40 |
# File 'lib/i_am_i_can/subject/role_querying.rb', line 38 def is_every? *roles roles.each { |role| return false if isnt? role } && true end |
#is_in_one_of?(*group_names) ⇒ Boolean Also known as: in_one_of?
59 60 61 |
# File 'lib/i_am_i_can/subject/role_querying.rb', line 59 def is_in_one_of? *group_names group_names.each { |name| return true if is_in_role_group? name } && false end |
#is_in_role_group?(name) ⇒ Boolean Also known as: in_role_group?
Group Querying ===
52 53 54 55 |
# File 'lib/i_am_i_can/subject/role_querying.rb', line 52 def is_in_role_group? name group_members = self.class.members_of_role_group(name) (roles & group_members).present? end |
#is_one_of!(*roles) ⇒ Object Also known as: is_one_of_roles!
32 33 34 |
# File 'lib/i_am_i_can/subject/role_querying.rb', line 32 def is_one_of! *roles raise VerificationFailed unless is_one_of? *roles end |
#is_one_of?(*roles) ⇒ Boolean Also known as: is_one_of_roles?
26 27 28 |
# File 'lib/i_am_i_can/subject/role_querying.rb', line 26 def is_one_of? *roles roles.each { |role| return true if is? role } && false end |
#isnt?(role) ⇒ Boolean
14 15 16 |
# File 'lib/i_am_i_can/subject/role_querying.rb', line 14 def isnt? role !is? role end |