class Saviour::Validator
Public Class Methods
new(model)
click to toggle source
# File lib/saviour/validator.rb, line 101 def initialize(model) raise(ConfigurationError, "Please provide an object compatible with Saviour.") unless model.class.respond_to?(:attached_files) @model = model end
Public Instance Methods
attached_files()
click to toggle source
# File lib/saviour/validator.rb, line 116 def attached_files @model.class.attached_files end
validate!()
click to toggle source
# File lib/saviour/validator.rb, line 106 def validate! validations.each do |column, declared_validations| raise(ConfigurationError, "There is no attachment defined as '#{column}'") unless attached_files.include?(column) if @model.send(column).changed? AttachmentValidator.new(@model, column, declared_validations).validate! end end end
validations()
click to toggle source
# File lib/saviour/validator.rb, line 120 def validations @model.class.__saviour_validations || {} end