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

- (AddPrivilegeAndAssignRoleToUserAction) initialize(user, privilege_sym, context, role_sym)



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

- (Object) context (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

- (Object) privilege (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

- (Object) role (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

- (Object) user (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

+ (Object) specific_actions(candidate)



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