Class Authorization::DevelopmentSupport::ChangeSupporter::CreateAndAssignRoleToUserAction
In: lib/declarative_authorization/development_support/change_supporter.rb
Parent: AbstractCompoundAction

Methods

apply   hash   new   specific_actions   to_a  

Attributes

context  [R] 
privilege  [R] 
role  [R] 
user  [R] 

Public Class methods

[Source]

     # File lib/declarative_authorization/development_support/change_supporter.rb, line 412
412:         def initialize (user, privilege_sym, context_sym, role_sym)
413:           @user, @privilege, @context, @role = user, privilege_sym, context_sym, role_sym
414:           @actions = [AddPrivilegeAndAssignRoleToUserAction.new(@user, @privilege, @context, role_sym)]
415:         end

[Source]

     # File lib/declarative_authorization/development_support/change_supporter.rb, line 400
400:         def self.specific_actions (candidate)
401:           privilege = AnalyzerEngine::Privilege.for_sym(
402:               candidate.failed_tests.first.privilege, candidate.engine)
403:           context = candidate.failed_tests.first.context
404:           user = candidate.failed_tests.first.user
405:           role = AnalyzerEngine::Role.for_sym(:change_supporter_new_role, candidate.engine)
406:           ([privilege] + privilege.ancestors).collect do |ancestor_privilege|
407:             new(user, ancestor_privilege.to_sym, context, role.to_sym)
408:           end
409:         end

Public Instance methods

[Source]

     # File lib/declarative_authorization/development_support/change_supporter.rb, line 417
417:         def apply (candidate)
418:           if AnalyzerEngine.apply_change(candidate.engine, [:add_role, @role])
419:             super(candidate)
420:           else
421:             false
422:           end
423:         end

[Source]

     # File lib/declarative_authorization/development_support/change_supporter.rb, line 425
425:         def hash
426:           to_a[0].hash + super
427:         end

[Source]

     # File lib/declarative_authorization/development_support/change_supporter.rb, line 429
429:         def to_a
430:           [[:add_role, @role]] + super
431:         end

[Validate]