Class: Authorization::Analyzer::MergeableRulesProcessor
- Inherits:
-
GeneralAuthorizationProcessor
- Object
- SexpProcessor
- GeneralAuthorizationProcessor
- Authorization::Analyzer::MergeableRulesProcessor
- Defined in:
- lib/declarative_authorization/authorization_rules_analyzer.rb
Instance Method Summary collapse
Methods inherited from GeneralAuthorizationProcessor
#analyze, #initialize, #process_arglist, #process_hash, #process_iter, #process_lit
Constructor Details
This class inherits a constructor from Authorization::Analyzer::GeneralAuthorizationProcessor
Instance Method Details
#analyze_rules ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/declarative_authorization/authorization_rules_analyzer.rb', line 69 def analyze_rules if #p @has_permission = .inject({}) do |memo, | key = [[:context], [:rules]] memo[key] ||= [] memo[key] << memo end .each do |key, rules| if rules.length > 1 rule_lines = rules.collect {|rule| rule[:line] } rules.each do |rule| @analyzer.reports << Report.new(:mergeable_rules, "", rule[:line], "Similar rules already in line(s) " + rule_lines.reject {|l| l == rule[:line] } * ", ") end end end end end |
#process_call(exp) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/declarative_authorization/authorization_rules_analyzer.rb', line 92 def process_call (exp) klass = exp.shift name = exp.shift case name when :role analyze_rules = [] s(:call, klass, name) when :has_permission_on arglist_line = exp[0].line arglist = process(exp.shift).shift context = arglist.shift args_hash = arglist.shift << { :context => context, :rules => [], :privilege => args_hash && args_hash[:to], # a hack: call exp line seems to be wrong :line => arglist_line } s(:call, klass, name) when :to .last[:privilege] = process(exp.shift).shift if s(:call, klass, name) when :if_attribute @in_if_attribute = true rules = process(exp.shift).shift .last[:rules] << rules if @in_if_attribute = false s(:call, klass, name) else s(:call, klass, name, process(exp.shift)) end end |