Sha256: c952185c6329c203263e5fa50359e588231126cc7d7c42b9a776991aac9078e1
Contents?: true
Size: 600 Bytes
Versions: 5
Compression:
Stored size: 600 Bytes
Contents
module AutoBuild class HasManyHook attr_reader :model, :association_name, :options def initialize(model, name, options) @model = model @association_name = name @options = options end def attach hook_code = code name = association_name record_options = options model.class_eval do after_initialize do |record| count = number_of_records_to_create(name, record_options) record.instance_eval(hook_code * count) end end end def code "self.#{association_name}.build;" end end end
Version data entries
5 entries across 5 versions & 1 rubygems