mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
26 lines
660 B
Ruby
26 lines
660 B
Ruby
module Concerns
|
|
module Contact
|
|
module Disclosable
|
|
extend ActiveSupport::Concern
|
|
|
|
class_methods do
|
|
attr_accessor :disclosable_attributes
|
|
end
|
|
|
|
included do
|
|
self.disclosable_attributes = %w[name email]
|
|
validate :validate_disclosed_attributes
|
|
end
|
|
|
|
private
|
|
|
|
def validate_disclosed_attributes
|
|
return if disclosed_attributes.empty?
|
|
|
|
has_undisclosable_attributes = (disclosed_attributes - self.class.disclosable_attributes)
|
|
.any?
|
|
errors.add(:disclosed_attributes, :invalid) if has_undisclosable_attributes
|
|
end
|
|
end
|
|
end
|
|
end
|