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.1.0.rc3 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.1.0.rc2 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.1.0.rc1 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.0.1 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.0.0 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.0.0.rc10 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.0.0.rc9 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.0.0.rc8 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.0.0.rc6 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.0.0.rc4 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.0.0.rc3 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.0.0.rc2 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.0.0.rc1 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.0.0.pre.beta.3 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.0.0.pre.beta.2 lib/locomotive/steam/models/associations/belongs_to.rb
locomotivecms_steam-1.0.0.pre.beta.1 lib/locomotive/steam/models/associations/belongs_to.rb