Class: Heimdallr::Validator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
lib/heimdallr/validator.rb

Overview

This is an internal class which runs security validations when Proxy::Record#save and Proxy::Record#save! are invoked. ActiveRecord::Base#save (and save!) clears the errors object internally, so this hack is required to avoid monkey-patching it.

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object

Run the record.heimdallr_validators on the current record, if any.



7
8
9
10
11
12
13
# File 'lib/heimdallr/validator.rb', line 7

def validate(record)
  if record.heimdallr_validators
    record.heimdallr_validators.each do |validator|
      validator.validate(record)
    end
  end
end