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
-
#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
- #apply(candidate) ⇒ Object
- #hash ⇒ Object
-
#initialize(user, privilege_sym, context_sym, role_sym) ⇒ CreateAndAssignRoleToUserAction
constructor
A new instance of CreateAndAssignRoleToUserAction.
- #to_a ⇒ Object
Methods inherited from AbstractCompoundAction
#resembles?, #reverse?, #weight
Methods inherited from AbstractAction
#eql?, #inspect, readable_info, #resembles?, #resembles_any?, #reverse?, #weight
Constructor Details
#initialize(user, privilege_sym, context_sym, role_sym) ⇒ CreateAndAssignRoleToUserAction
Returns 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
#context ⇒ Object (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 |
#privilege ⇒ Object (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 |
#role ⇒ Object (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 |
#user ⇒ Object (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
.specific_actions(candidate) ⇒ Object
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
#apply(candidate) ⇒ Object
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 |
#hash ⇒ Object
425 426 427 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 425 def hash to_a[0].hash + super end |
#to_a ⇒ Object
429 430 431 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 429 def to_a [[:add_role, @role]] + super end |