Sha256: cdbfed1015194a2c16f5cf9f6b746917e5ba5da3347ca8b3b70dc84bd63d8962
Contents?: true
Size: 646 Bytes
Versions: 6
Compression:
Stored size: 646 Bytes
Contents
class Acfs::Resource # module Validation def valid?(*args) super remote_errors.each {|f, e| errors.add f, e } errors.empty? end def remote_errors @remote_errors ||= ActiveModel::Errors.new self end def remote_errors=(errors) (errors || []).each do |field, errs| errs.each do |err| self.errors.add field.to_sym, err remote_errors.add field.to_sym, err end end end def save!(*_) unless valid?(new? ? :create : :save) raise ::Acfs::InvalidResource.new resource: self, errors: errors.to_a end super end end end
Version data entries
6 entries across 6 versions & 1 rubygems