Sha256: 45fcc8a5dcb660f20c9f32e2029d40176fbf47b0cd3e18a1841d491bf2b3999a

Contents?: true

Size: 779 Bytes

Versions: 19

Compression:

Stored size: 779 Bytes

Contents

module Locomotive::Steam
  module Models

    class ManyToManyAssociation < ReferencedAssociation

      def __load__
        key = @repository.k(:_id, :in)

        @repository.local_conditions[key] = @entity[__target_key__]

        # use order_by from options as the default one for further queries
        @repository.local_conditions[:order_by] = @options[:order_by] unless @options[:order_by].blank?

        # all the further calls (method_missing) will be delegated to @repository
        @repository
      end

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

        attributes.delete(__name__)
      end

      def __target_key__
        :"#{__name__.to_s.singularize}_ids"
      end


    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
locomotivecms_steam-1.1.2 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.1.1 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.1.0 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.1.0.rc3 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.1.0.rc2 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.1.0.rc1 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.1 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0.rc10 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0.rc9 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0.rc8 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0.rc6 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0.rc4 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0.rc3 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0.rc2 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0.rc1 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0.pre.beta.3 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0.pre.beta.2 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0.pre.beta.1 lib/locomotive/steam/models/associations/many_to_many.rb