Class: Authorization::DevelopmentSupport::ChangeSupporter::AddPrivilegeAndAssignRoleToUserAction

Inherits:
AbstractCompoundAction show all
Defined in:
lib/declarative_authorization/development_support/change_supporter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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.



406
407
408
409
410
411
412
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 406

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

#contextObject (readonly)

Returns the value of attribute context.



405
406
407
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 405

def context
  @context
end

#privilegeObject (readonly)

Returns the value of attribute privilege.



405
406
407
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 405

def privilege
  @privilege
end

#roleObject (readonly)

Returns the value of attribute role.



405
406
407
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 405

def role
  @role
end

#userObject (readonly)

Returns the value of attribute user.



405
406
407
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 405

def user
  @user
end

Class Method Details

.specific_actions(candidate) ⇒ Object



393
394
395
396
397
398
399
400
401
402
403
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 393

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