Class: Authorization::DevelopmentSupport::Analyzer::ProposedPrivilegeHierarchyAnalyzer

Inherits:
GeneralRulesAnalyzer
  • Object
show all
Defined in:
lib/declarative_authorization/development_support/analyzer.rb

Instance Method Summary collapse

Methods inherited from GeneralRulesAnalyzer

#analyze, #initialize

Constructor Details

This class inherits a constructor from Authorization::DevelopmentSupport::Analyzer::GeneralRulesAnalyzer

Instance Method Details

#analyze_privilege(privilege) ⇒ Object

TODO respect, consider contexts



128
129
130
131
132
133
# File 'lib/declarative_authorization/development_support/analyzer.rb', line 128

def analyze_privilege (privilege)
  privileges.find do |other_privilege|
    other_privilege != privilege and
        other_privilege.rules.all? {|rule| rule.privileges.include?(privilege)}
  end
end

#message(privilege) ⇒ Object



135
136
137
138
139
# File 'lib/declarative_authorization/development_support/analyzer.rb', line 135

def message (privilege)
  other_privilege = analyze_privilege(privilege)
  "Privilege #{other_privilege.to_sym} is always used together with #{privilege.to_sym}. " +
      "Consider to include #{other_privilege.to_sym} in #{privilege.to_sym}."
end