Sha256: 58f3288310c09e55db2f774eeba61dd57fe0964bc78c0d5ad772fa5c14cb4233

Contents?: true

Size: 711 Bytes

Versions: 13

Compression:

Stored size: 711 Bytes

Contents

module Superstore
  module Associations
    class Association
      attr_reader :owner, :reflection
      delegate :options, to: :reflection

      def initialize(owner, reflection)
        @owner = owner
        @reflection = reflection
      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
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
superstore-2.4.4 lib/superstore/associations/association.rb
superstore-2.4.3 lib/superstore/associations/association.rb
superstore-2.4.2 lib/superstore/associations/association.rb
superstore-2.4.1 lib/superstore/associations/association.rb
superstore-2.4.0 lib/superstore/associations/association.rb
superstore-2.3.0 lib/superstore/associations/association.rb
superstore-2.2.0 lib/superstore/associations/association.rb
superstore-2.1.3 lib/superstore/associations/association.rb
superstore-2.1.2 lib/superstore/associations/association.rb
superstore-2.1.1 lib/superstore/associations/association.rb
superstore-2.1.0 lib/superstore/associations/association.rb
superstore-2.0.1 lib/superstore/associations/association.rb
superstore-2.0.0 lib/superstore/associations/association.rb