Sha256: 9d37c7bc2ba8230e10b9342d5edaebb95e833a931826f94b6aae32a086cdc167
Contents?: true
Size: 798 Bytes
Versions: 2
Compression:
Stored size: 798 Bytes
Contents
module Superstore module Associations class Association attr_reader :owner, :reflection delegate :options, to: :reflection def initialize(owner, reflection) @owner = owner @reflection = reflection reset end def association_class association_class_name.constantize end def association_class_name reflection.polymorphic? ? owner.send(reflection.polymorphic_column) : reflection.class_name end def target=(target) @target = target loaded! end def target @target end def loaded? @loaded end def loaded! @loaded = true end def reset @loaded = false @target = nil end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
superstore-3.0.0 | lib/superstore/associations/association.rb |
superstore-2.5.0 | lib/superstore/associations/association.rb |