Sha256: e89d126e6df17ae1efa7d751c06f658aeb6e567877d11656a89122a95dba3d23
Contents?: true
Size: 451 Bytes
Versions: 14
Compression:
Stored size: 451 Bytes
Contents
module NinjaModel class Base include ActiveModel::Validations define_model_callbacks :validation end module Validation def save(options={}) run_callbacks :validation do valid?(options.is_a?(Hash) ? options[:context] : nil) ? super : false end end def valid?(context = nil) context ||= (persisted? ? :update : :create) output = super(context) errors.empty? && output end end end
Version data entries
14 entries across 14 versions & 1 rubygems