Sha256: fe0bf84caf75734b339d3813b80f47feabe4cb1e0623b77fe1fe02a2400a0489
Contents?: true
Size: 662 Bytes
Versions: 39
Compression:
Stored size: 662 Bytes
Contents
# frozen_string_literal: true module Cocina module Models # Validate upon construction module Validatable extend ActiveSupport::Concern class_methods do def new(attributes = default_attributes, safe = false, validate = true, &block) Validators::Validator.validate(self, attributes) if validate super(attributes, safe, &block) end end def new(*args) validate = args.first.delete(:validate) if args.present? new_model = super(*args) Validators::Validator.validate(new_model.class, new_model) if validate || validate.nil? new_model end end end end
Version data entries
39 entries across 39 versions & 1 rubygems