Merge branch 'master' into notes
[rails.git] / app / models / acl.rb
1 class Acl < ActiveRecord::Base
2   def self.match(address, domain = nil)
3     if domain
4       condition = Acl.where("address >>= ? OR domain = ?", address, domain)
5     else
6       condition = Acl.where("address >>= ?", address)
7     end
8   end
9
10   def self.no_account_creation(address, domain = nil)
11     self.match(address, domain).where(:k => "no_account_creation").exists?
12   end
13
14   def self.no_trace_download(address, domain = nil)
15     self.match(address, domain).where(:k => "no_trace_download").exists?
16   end
17 end