class Authorization::DevelopmentSupport::ChangeSupporter::RemoveRoleFromUserAction
Attributes
role[R]
user[R]
Public Class Methods
new(user, role_sym)
click to toggle source
# File lib/declarative_authorization/development_support/change_supporter.rb, line 505 def initialize (user, role_sym) @user, @role = user, role_sym end
specific_actions(candidate)
click to toggle source
# File lib/declarative_authorization/development_support/change_supporter.rb, line 492 def self.specific_actions (candidate) privilege = candidate.failed_tests.first.privilege context = candidate.failed_tests.first.context user = candidate.failed_tests.first.user roles_for_privilege = AnalyzerEngine::Role.all_for_privilege(privilege, context, candidate.engine).map(&:to_sym) user.role_symbols.collect {|role_sym| AnalyzerEngine::Role.for_sym(role_sym, candidate.engine)}. select {|role| roles_for_privilege.include?(role.to_sym)}. collect do |role| new(user, role.to_sym) end end
Public Instance Methods
apply(candidate)
click to toggle source
# File lib/declarative_authorization/development_support/change_supporter.rb, line 509 def apply (candidate) # beware of shallow copies! cloned_user = @user.clone user_index = candidate.users.index(@user) raise "Cannot find #{@user.inspect} in users array" unless user_index candidate.users[user_index] = cloned_user cloned_user.role_symbols.delete(@role) raise "User#role_symbols immutable or user only shallowly cloned!" if cloned_user.role_symbols == @user.role_symbols true end
hash()
click to toggle source
# File lib/declarative_authorization/development_support/change_supporter.rb, line 520 def hash to_a[0,2].hash + @user.login.hash end
resembles?(spec)
click to toggle source
Calls superclass method
Authorization::DevelopmentSupport::ChangeSupporter::AbstractAction#resembles?
# File lib/declarative_authorization/development_support/change_supporter.rb, line 530 def resembles? (spec) super(spec[0,2]) and (spec.length == 2 or spec[2] == @user.login) end
reverse?(other)
click to toggle source
# File lib/declarative_authorization/development_support/change_supporter.rb, line 524 def reverse? (other) (other.is_a?(AssignRoleToUserAction) or other.is_a?(AbstractCompoundAction)) and other.reverse?(self) end
to_a()
click to toggle source
# File lib/declarative_authorization/development_support/change_supporter.rb, line 534 def to_a [:remove_role_from_user, @role, @user] end