| Class | Authorization::DevelopmentSupport::ChangeSupporter::AssignPrivilegeToRoleAction |
| In: |
lib/declarative_authorization/development_support/change_supporter.rb
|
| Parent: | AbstractAction |
| context | [R] | |
| privilege | [R] | |
| role | [R] |
# 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
# 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
# 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