Sha256: 6c88a99425186cd38caf072ed37372c4cb192083bb1c952596948ed976acc0d0
Contents?: true
Size: 649 Bytes
Versions: 1
Compression:
Stored size: 649 Bytes
Contents
module NinjaModel module Validation extend ActiveSupport::Concern included do include ActiveModel::Validations include ActiveModel::Validations::Callbacks define_model_callbacks :validation end def save(options={}) perform_validations(options) ? super : false end def valid?(context = nil) context ||= (persisted? ? :update : :create) output = super(context) errors.empty? && output end protected def perform_validations(options) perform_validation = options[:validate] != false perform_validation ? valid?(options[:context]) : true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ninja-model-0.9.3 | lib/ninja_model/validation.rb |