Sha256: ef6bed8ff68a51f96b603bc893d43706cc229f2104c752a1c0ba9bb906945569
Contents?: true
Size: 609 Bytes
Versions: 7
Compression:
Stored size: 609 Bytes
Contents
module NinjaModel module Validation extend ActiveSupport::Concern include ActiveModel::Validations included do include ActiveModel::Validations::Callbacks 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
7 entries across 7 versions & 1 rubygems