Permalink
Browse files

Change creation of the perm hash to use a lambda

  • Loading branch information...
1 parent c81f489 commit c62e03b2159524ca791e60a82bee572329a61283 @wingrunr21 wingrunr21 committed Sep 9, 2011
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/gitolite/config/repo.rb
@@ -9,15 +9,17 @@ class Repo
def initialize(name)
@name = name
- @permissions = Array.new.push(Hash.new {|k,v| k[v] = Hash.new{|k2, v2| k2[v2] = [] }})
+ #Store the perm hash in a lambda since we have to create a new one on every deny rule
+ @perm_hash_lambda = lambda { Hash.new {|k,v| k[v] = Hash.new{|k2, v2| k2[v2] = [] }} }
+ @permissions = Array.new.push(@perm_hash_lambda.call)
@config = {}
end
def add_permission(perm, refex = "", *users)
if ALLOWED_PERMISSIONS.include? perm
#Handle deny rules
if perm == '-'
- @permissions.push(Hash.new {|k,v| k[v] = Hash.new{|k2, v2| k2[v2] = [] }})
+ @permissions.push(@perm_hash_lambda.call)
end
@permissions.last[perm][refex].concat users.flatten

0 comments on commit c62e03b

Please sign in to comment.