Add support for domain based ACLs
[rails.git] / app / models / acl.rb
index 8eeb2310a77674545fa68c2c1d5d8f7deb75e7e0..e19c6988b4100e59f61e5a5c5a503c9e4c97b4f0 100644 (file)
@@ -1,3 +1,9 @@
 class Acl < ActiveRecord::Base
-  scope :address, lambda { |address| where("address >> ?", address) }
+  def self.match(address, domain = nil)
+    if domain
+      condition = Acl.where("address >> ? OR domain = ?", address, domain)
+    else
+      condition = Acl.where("address >> ?", address)
+    end
+  end
 end