module IAmICan::Subject::PermissionQuerying
Public Instance Methods
can!(action, o = nil, obj: o)
click to toggle source
# File lib/i_am_i_can/subject/permission_querying.rb, line 17 def can! action, o = nil, obj: o raise InsufficientPermission if cannot? action, obj true end
can?(action, o = nil, obj: o, without_group: false)
click to toggle source
TODO: without: :group
# File lib/i_am_i_can/subject/permission_querying.rb, line 7 def can? action, o = nil, obj: o, without_group: false temporarily_can?(action, obj) || stored_can?(action, obj) || group_can?(action, obj, without_group) end
can_each!(actions, o = nil, obj: o)
click to toggle source
# File lib/i_am_i_can/subject/permission_querying.rb, line 38 def can_each! actions, o = nil, obj: o actions.each { |action| can! action, obj } && true end
Also aliased as: can_every!
can_each?(actions, o = nil, obj: o)
click to toggle source
# File lib/i_am_i_can/subject/permission_querying.rb, line 31 def can_each? actions, o = nil, obj: o # TODO: using `matched_all?` actions.each { |action| return false if cannot? action, obj } && true end
Also aliased as: can_every?
can_one_of!(actions, o = nil, obj: o)
click to toggle source
# File lib/i_am_i_can/subject/permission_querying.rb, line 26 def can_one_of! actions, o = nil, obj: o raise InsufficientPermission unless can_one_of? actions, obj true end
can_one_of?(actions, o = nil, obj: o)
click to toggle source
# File lib/i_am_i_can/subject/permission_querying.rb, line 22 def can_one_of? actions, o = nil, obj: o can? actions, obj end
cannot?(action, o = nil, obj: o)
click to toggle source
# File lib/i_am_i_can/subject/permission_querying.rb, line 13 def cannot? action, o = nil, obj: o !can? action, obj end
group_can?(action, obj, without_group = false)
click to toggle source
# File lib/i_am_i_can/subject/permission_querying.rb, line 53 def group_can? action, obj, without_group = false return false if without_group || i_am_i_can.without_group _roles._role_groups._permissions.matched?(action, obj) end
stored_can?(action, obj)
click to toggle source
# File lib/i_am_i_can/subject/permission_querying.rb, line 49 def stored_can? action, obj _roles.can?(action, obj) end
temporarily_can?(action, obj)
click to toggle source
# File lib/i_am_i_can/subject/permission_querying.rb, line 44 def temporarily_can? action, obj return false if try(:temporary_roles).blank? valid_temporary_roles.can?(action, obj) end