Sha256: 31026ddc2e9b20162ec7473e70665389c37ef63c1e2873ad65268fda96633fb8

Contents?: true

Size: 896 Bytes

Versions: 7

Compression:

Stored size: 896 Bytes

Contents

# frozen_string_literal: true

module ROM
  module Mongo
    module Commands
      module Helper
        private

        # @api private
        def dataset
          relation.dataset
        end

        # @api private
        def pk
          return {} unless dataset.respond_to?(:filter)

          dataset.filter.transform_keys(&:to_sym)
        end

        # @api private
        def process_with_schema(attributes)
          schema.to_output_hash.call(attributes)
        end

        # @api private
        def schema
          relation.schema
        end

        # @api private
        def schema_attributes
          schema
            .attributes
            .map(&:name)
            .each_with_object({}) { |item, hash| hash[item] = true }
        end

        # @api private
        def projection
          { projection: schema_attributes }
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rom-mongodb-0.1.6 lib/rom/mongo/commands/helper.rb
rom-mongodb-0.1.5 lib/rom/mongo/commands/helper.rb
rom-mongodb-0.1.4 lib/rom/mongo/commands/helper.rb
rom-mongodb-0.1.3 lib/rom/mongo/commands/helper.rb
rom-mongodb-0.1.2 lib/rom/mongo/commands/helper.rb
rom-mongodb-0.1.1 lib/rom/mongo/commands/helper.rb
rom-mongodb-0.1.0 lib/rom/mongo/commands/helper.rb