Class Authorization::DevelopmentSupport::ChangeSupporter::AssignPrivilegeToRoleAction
In: lib/declarative_authorization/development_support/change_supporter.rb
Parent: AbstractAction

Methods

apply   new   reverse?   specific_actions   to_a  

Attributes

context  [R] 
privilege  [R] 
role  [R] 

Public Class methods

[Source]

     # File lib/declarative_authorization/development_support/change_supporter.rb, line 329
329:         def initialize (privilege_sym, context, role_sym)
330:           @privilege, @context, @role = privilege_sym, context, role_sym
331:         end

[Source]

     # File lib/declarative_authorization/development_support/change_supporter.rb, line 314
314:         def self.specific_actions (candidate)
315:           privilege = AnalyzerEngine::Privilege.for_sym(
316:               candidate.failed_tests.first.privilege, candidate.engine)
317:           context = candidate.failed_tests.first.context
318:           user = candidate.failed_tests.first.user
319:           ([privilege] + privilege.ancestors).collect do |ancestor_privilege|
320:             user.role_symbols.collect {|role_sym| AnalyzerEngine::Role.for_sym(role_sym, candidate.engine) }.
321:                 collect {|role| [role] + role.ancestors}.flatten.uniq.collect do |role|
322:               # apply checks later if privilege is already present in that role
323:               new(ancestor_privilege.to_sym, context, role.to_sym)
324:             end
325:           end.flatten
326:         end

Public Instance methods

[Source]

     # File lib/declarative_authorization/development_support/change_supporter.rb, line 333
333:         def apply (candidate)
334:           AnalyzerEngine.apply_change(candidate.engine, to_a)
335:         end

[Source]

     # File lib/declarative_authorization/development_support/change_supporter.rb, line 337
337:         def reverse? (other)
338:           other.is_a?(RemovePrivilegeFromRoleAction) and
339:               other.privilege == @privilege and
340:               other.context == @context and
341:               other.role == @role
342:         end

[Source]

     # File lib/declarative_authorization/development_support/change_supporter.rb, line 344
344:         def to_a
345:           [:add_privilege, @privilege, @context, @role]
346:         end

[Validate]