mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 02:35:57 +02:00
22 lines
558 B
Ruby
22 lines
558 B
Ruby
module Contact::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
|