]> git.openstreetmap.org Git - rails.git/blob - app/models/acl.rb
Merge remote-tracking branch 'openstreetmap/pull/1495'
[rails.git] / app / models / acl.rb
1 class Acl < ActiveRecord::Base
2   validates :k, :presence => true
3
4   def self.match(address, domain = nil)
5     if domain
6       Acl.where("address >>= ? OR domain = ?", address, domain)
7     else
8       Acl.where("address >>= ?", address)
9     end
10   end
11
12   def self.no_account_creation(address, domain = nil)
13     match(address, domain).where(:k => "no_account_creation").exists?
14   end
15
16   def self.no_note_comment(address, domain = nil)
17     match(address, domain).where(:k => "no_note_comment").exists?
18   end
19
20   def self.no_trace_download(address, domain = nil)
21     match(address, domain).where(:k => "no_trace_download").exists?
22   end
23 end