Sha256: 73e29422b8dcf8393ca497645d43aa39e123bc71d088d19965fa3c1afc525e3c
Contents?: true
Size: 520 Bytes
Versions: 1
Compression:
Stored size: 520 Bytes
Contents
module Superstore module Associations class HasMany < Association def reader unless loaded? self.target = load_collection end target end def writer(records) reader.instance_variable_set :@records, records reader.instance_variable_set :@loaded, true loaded! end private def load_collection association_class.where(reflection.foreign_key => owner.try(reflection.primary_key)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
superstore-2.0.0 | lib/superstore/associations/has_many.rb |