Class: Authorization::DevelopmentSupport::ChangeSupporter::CreateAndAssignRoleToUserAction
- Inherits:
-
AbstractCompoundAction
- Object
- AbstractAction
- AbstractCompoundAction
- Authorization::DevelopmentSupport::ChangeSupporter::CreateAndAssignRoleToUserAction
- Defined in:
- lib/declarative_authorization/development_support/change_supporter.rb
Instance Attribute Summary (collapse)
-
- (Object) context
readonly
Returns the value of attribute context.
-
- (Object) privilege
readonly
Returns the value of attribute privilege.
-
- (Object) role
readonly
Returns the value of attribute role.
-
- (Object) user
readonly
Returns the value of attribute user.
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Object) apply(candidate)
- - (Object) hash
-
- (CreateAndAssignRoleToUserAction) initialize(user, privilege_sym, context_sym, role_sym)
constructor
A new instance of CreateAndAssignRoleToUserAction.
- - (Object) to_a
Methods inherited from AbstractCompoundAction
#resembles?, #reverse?, #weight
Methods inherited from AbstractAction
#eql?, #inspect, readable_info, #resembles?, #resembles_any?, #reverse?, #weight
Constructor Details
- (CreateAndAssignRoleToUserAction) initialize(user, privilege_sym, context_sym, role_sym)
A new instance of CreateAndAssignRoleToUserAction
412 413 414 415 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 412 def initialize (user, privilege_sym, context_sym, role_sym) @user, @privilege, @context, @role = user, privilege_sym, context_sym, role_sym @actions = [AddPrivilegeAndAssignRoleToUserAction.new(@user, @privilege, @context, role_sym)] end |
Instance Attribute Details
- (Object) context (readonly)
Returns the value of attribute context
411 412 413 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 411 def context @context end |
- (Object) privilege (readonly)
Returns the value of attribute privilege
411 412 413 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 411 def privilege @privilege end |
- (Object) role (readonly)
Returns the value of attribute role
411 412 413 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 411 def role @role end |
- (Object) user (readonly)
Returns the value of attribute user
411 412 413 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 411 def user @user end |
Class Method Details
+ (Object) specific_actions(candidate)
400 401 402 403 404 405 406 407 408 409 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 400 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 role = AnalyzerEngine::Role.for_sym(:change_supporter_new_role, candidate.engine) ([privilege] + privilege.ancestors).collect do |ancestor_privilege| new(user, ancestor_privilege.to_sym, context, role.to_sym) end end |
Instance Method Details
- (Object) apply(candidate)
417 418 419 420 421 422 423 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 417 def apply (candidate) if AnalyzerEngine.apply_change(candidate.engine, [:add_role, @role]) super(candidate) else false end end |
- (Object) hash
425 426 427 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 425 def hash to_a[0].hash + super end |
- (Object) to_a
429 430 431 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 429 def to_a [[:add_role, @role]] + super end |