]> git.openstreetmap.org Git - rails.git/blob - app/models/acl.rb
Merge branch 'master' into openstreetbugs
[rails.git] / app / models / acl.rb
1 class Acl < ActiveRecord::Base
2   def self.find_by_address(address, options)
3     self.with_scope(:find => {:conditions => ["#{inet_aton} & netmask = address", address]}) do
4       return self.find(:first, options)
5     end
6   end
7
8   def self.find_all_by_address(address, options)
9     self.with_scope(:find => {:conditions => ["#{inet_aton} & netmask = address", address]}) do
10       return self.find(:all, options)
11     end
12   end
13
14 private
15
16   def self.inet_aton
17     if self.connection.adapter_name == "MySQL"
18       "inet_aton(?)"
19     else
20       "?"
21     end
22   end
23 end