Class: Authorization::DevelopmentSupport::ChangeSupporter::AddPrivilegeAndAssignRoleToUserAction
- Inherits:
-
AbstractCompoundAction
- Object
- AbstractAction
- AbstractCompoundAction
- Authorization::DevelopmentSupport::ChangeSupporter::AddPrivilegeAndAssignRoleToUserAction
- Defined in:
- lib/declarative_authorization/development_support/change_supporter.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#privilege ⇒ Object
readonly
Returns the value of attribute privilege.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(user, privilege_sym, context, role_sym) ⇒ AddPrivilegeAndAssignRoleToUserAction
constructor
A new instance of AddPrivilegeAndAssignRoleToUserAction.
Methods inherited from AbstractCompoundAction
#apply, #hash, #resembles?, #reverse?, #to_a, #weight
Methods inherited from AbstractAction
#apply, #eql?, #hash, #inspect, readable_info, #resembles?, #resembles_any?, #reverse?, #to_a, #weight
Constructor Details
#initialize(user, privilege_sym, context, role_sym) ⇒ AddPrivilegeAndAssignRoleToUserAction
Returns a new instance of AddPrivilegeAndAssignRoleToUserAction.
448 449 450 451 452 453 454 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 448 def initialize (user, privilege_sym, context, role_sym) @user, @privilege, @context, @role = user, privilege_sym, context, role_sym @actions = [ AssignRoleToUserAction.new(@user, @role), AssignPrivilegeToRoleAction.new(@privilege, @context, @role) ] end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
447 448 449 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 447 def context @context end |
#privilege ⇒ Object (readonly)
Returns the value of attribute privilege.
447 448 449 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 447 def privilege @privilege end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
447 448 449 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 447 def role @role end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
447 448 449 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 447 def user @user end |
Class Method Details
.specific_actions(candidate) ⇒ Object
435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 435 def self.specific_actions (candidate) privilege = AnalyzerEngine::Privilege.for_sym( candidate.failed_tests.first.privilege, candidate.engine) context = candidate.failed_tests.first.context user = candidate.failed_tests.first.user ([privilege] + privilege.ancestors).collect do |ancestor_privilege| AnalyzerEngine::Role.all(candidate.engine).collect do |role| new(user, ancestor_privilege.to_sym, context, role.to_sym) end end.flatten end |