Sha256: c4e12237727dce0c801105d0125a68263c3aede2076fe1f8b0794b71f97a1d30

Contents?: true

Size: 785 Bytes

Versions: 31

Compression:

Stored size: 785 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

31 entries across 31 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.8.0.alpha1 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.7.1 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.7.0 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.6.1 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.6.0 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.6.0.rc1 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.6.0.beta1 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.5.3 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.5.2 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.5.1 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.5.0 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.5.0.rc1 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.5.0.rc0 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.5.0.beta3 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.5.0.beta2 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.5.0.beta1 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.4.1 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.4.0 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.4.0.rc2 lib/locomotive/steam/models/associations/many_to_many.rb