Reuse identical contacts

#746
This commit is contained in:
Artur Beljajev 2018-03-05 10:59:14 +02:00
parent 84bc0f8914
commit 53a34ee2d6
9 changed files with 94 additions and 12 deletions

View file

@ -0,0 +1,18 @@
module Concerns::Contact::Identical
extend ActiveSupport::Concern
ATTRIBUTE_FILTER = %w[
name
ident
ident_type
ident_country_code
phone
email
]
private_constant :ATTRIBUTE_FILTER
def identical(registrar)
self.class.where(attributes.slice(*ATTRIBUTE_FILTER)).where(registrar: registrar)
.where.not(id: id).take
end
end