1 # == Schema Information
5 # id :bigint(8) not null, primary key
15 # index_acls_on_address (address) USING gist
16 # index_acls_on_domain (domain)
17 # index_acls_on_mx (mx)
20 class Acl < ApplicationRecord
21 validates :k, :presence => true
23 def self.match(address, options = {})
24 acls = Acl.where("address >>= ?", address)
27 labels = options[:domain].split(".")
30 acls = acls.or(Acl.where(:domain => labels.join(".")))
35 acls = acls.or(Acl.where(:mx => options[:mx])) if options[:mx]
40 def self.no_account_creation(address, options = {})
41 match(address, options).exists?(:k => "no_account_creation")
44 def self.allow_account_creation(address, options = {})
45 match(address, options).exists?(:k => "allow_account_creation")
48 def self.no_note_comment(address, domain = nil)
49 match(address, :domain => domain).exists?(:k => "no_note_comment")
52 def self.no_trace_download(address, domain = nil)
53 match(address, :domain => domain).exists?(:k => "no_trace_download")