Sha256: 10281c175b17694c2a1c4921bf7da11adf15828d7b7927fd4768784f2b7879d9
Contents?: true
Size: 592 Bytes
Versions: 4
Compression:
Stored size: 592 Bytes
Contents
# frozen_string_literal: true require 'lazy_record/dynamic_modules' module LazyRecord # After #initialize callbacks for validations and setting object id. module Callbacks def new(opts = {}, &block) @all ||= Relation.new(model: self) instance = super(opts, &block) if instance.respond_to?(:validation) instance = instance.validation(*@validations) end add_id(instance) end def add_id(instance) if instance all << instance instance.send(:id=, count) end instance end private :add_id end end
Version data entries
4 entries across 4 versions & 1 rubygems