Sha256: a17fe8e1acccf10464c50d5f14057cbc6c2ed8e6b1fea71697762b9357f40d8c

Contents?: true

Size: 549 Bytes

Versions: 36

Compression:

Stored size: 549 Bytes

Contents

module Locomotive::Steam
  module Models

    class BelongsToAssociation < ReferencedAssociation

      def __load__
        target_id = @entity[__target_key__]
        target    = @repository.find(target_id)

        # replace the proxy class by the real target entity
        @entity[__name__] = target
      end

      def __serialize__(attributes)
        attributes[__target_key__] = attributes[__name__].try(:_id)

        attributes.delete(__name__)
      end

      def __target_key__
        :"#{__name__}_id"
      end

    end

  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
locomotivecms_steam-1.5.0.beta3 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.5.0.beta2 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.5.0.beta1 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.4.1 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.4.0 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.4.0.rc2 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.4.0.rc1 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.4.0.pre.rc.1 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.3.0 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.3.0.rc2 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.1.2 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.2.1 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.3.0.rc1 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.2.0 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.2.0.rc3 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.2.0.rc2 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.2.0.rc1 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.2.0.beta1 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.1.1 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.1.0 lib/locomotive/steam/models/associations/belongs_to.rb