Class: Authorization::DevelopmentSupport::ChangeSupporter::RemovePrivilegeFromRoleAction
- Inherits:
-
AbstractAction
- Object
- AbstractAction
- Authorization::DevelopmentSupport::ChangeSupporter::RemovePrivilegeFromRoleAction
- 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.
Class Method Summary collapse
Instance Method Summary collapse
- #apply(candidate) ⇒ Object
-
#initialize(privilege_sym, context, role_sym) ⇒ RemovePrivilegeFromRoleAction
constructor
A new instance of RemovePrivilegeFromRoleAction.
- #reverse?(other) ⇒ Boolean
- #to_a ⇒ Object
Methods inherited from AbstractAction
#eql?, #hash, #inspect, readable_info, #resembles?, #resembles_any?, #weight
Constructor Details
#initialize(privilege_sym, context, role_sym) ⇒ RemovePrivilegeFromRoleAction
Returns a new instance of RemovePrivilegeFromRoleAction.
472 473 474 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 472 def initialize (privilege_sym, context, role_sym) @privilege, @context, @role = privilege_sym, context, role_sym end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
471 472 473 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 471 def context @context end |
#privilege ⇒ Object (readonly)
Returns the value of attribute privilege.
471 472 473 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 471 def privilege @privilege end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
471 472 473 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 471 def role @role end |
Class Method Details
.specific_actions(candidate) ⇒ Object
458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 458 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| user.role_symbols.collect {|role_sym| AnalyzerEngine::Role.for_sym(role_sym, candidate.engine) }. collect {|role| [role] + role.ancestors}.flatten.uniq.collect do |role| new(ancestor_privilege.to_sym, context, role.to_sym) end end.flatten end |
Instance Method Details
#apply(candidate) ⇒ Object
476 477 478 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 476 def apply (candidate) AnalyzerEngine.apply_change(candidate.engine, to_a) end |
#reverse?(other) ⇒ Boolean
480 481 482 483 484 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 480 def reverse? (other) (other.is_a?(AssignPrivilegeToRoleAction) or other.is_a?(AbstractCompoundAction)) and other.reverse?(self) end |
#to_a ⇒ Object
486 487 488 |
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 486 def to_a [:remove_privilege, @privilege, @context, @role] end |