Sha256: 5322686fa6c2333428fae3e9533415626ec502545070d110687a22b422bbafae

Contents?: true

Size: 611 Bytes

Versions: 4

Compression:

Stored size: 611 Bytes

Contents

module Locomotive::Steam
  module Models

    class ManyToManyAssociation < ReferencedAssociation

      def __load__
        source_key = :"#{@options[:association_name].to_s.singularize}_ids"
        key = @repository.k(:_id, :in)

        @repository.local_conditions[key] = @entity[source_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

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
locomotivecms_steam-1.0.0.pre.alpha.3 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0.pre.alpha.2 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0.pre.alpha.1 lib/locomotive/steam/models/associations/many_to_many.rb
locomotivecms_steam-1.0.0.pre.alpha lib/locomotive/steam/models/associations/many_to_many.rb