Class: Progstr::Filer::Validation::AttachmentPropertyValidator

Inherits:
ActiveModel::Validations::InclusionValidator
  • Object
show all
Defined in:
lib/filer/validation.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ AttachmentPropertyValidator

Returns a new instance of AttachmentPropertyValidator.



39
40
41
42
# File 'lib/filer/validation.rb', line 39

def initialize(options)
  @property = options[:property]
  super(options)
end

Instance Method Details

#validate_each(record, attribute, attachment) ⇒ Object



44
45
46
47
48
49
# File 'lib/filer/validation.rb', line 44

def validate_each(record, attribute, attachment)
  unless attachment.pre_validated
    property_value = attachment.send(@property)
    super(record, attribute, property_value) unless attachment.nil? || attachment.blank? || property_value.nil?
  end
end