Sha256: f80564c6eea333aae02596c9db0491b84dbc25c11d02c5fcba39765f0cf37004

Contents?: true

Size: 752 Bytes

Versions: 14

Compression:

Stored size: 752 Bytes

Contents

# In-memory query designed for use with the MemoryRepository for specs

module Praxis::Mapper
  module Support
    class MemoryQuery < Praxis::Mapper::Query::Base

      def collection
        connection.collection(model.table_name)
      end

      def _multi_get(key, values)
        results = values.collect do |value|
          connection.all(model, key =>  value)
        end.flatten.uniq

        results.select do |result|
          where.nil? || where.all? do |k,v|
            result[k] == v
          end
        end
      end

      def _execute
        connection.all(model.table_name, self.where||{}).to_a
      end

      # Subclasses Must Implement
      def describe
        raise "subclass responsibility"
      end

    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
praxis-mapper-4.5 lib/praxis-mapper/support/memory_query.rb
praxis-mapper-4.4.1 lib/praxis-mapper/support/memory_query.rb
praxis-mapper-4.4 lib/praxis-mapper/support/memory_query.rb
praxis-mapper-4.3 lib/praxis-mapper/support/memory_query.rb
praxis-mapper-4.2 lib/praxis-mapper/support/memory_query.rb
praxis-mapper-4.1.2 lib/praxis-mapper/support/memory_query.rb
praxis-mapper-4.1.1 lib/praxis-mapper/support/memory_query.rb
praxis-mapper-4.1 lib/praxis-mapper/support/memory_query.rb
praxis-mapper-4.0 lib/praxis-mapper/support/memory_query.rb
praxis-mapper-3.4.0 lib/praxis-mapper/support/memory_query.rb
praxis-mapper-3.3 lib/praxis-mapper/support/memory_query.rb
praxis-mapper-3.2 lib/praxis-mapper/support/memory_query.rb
praxis-mapper-3.1.2 lib/praxis-mapper/support/memory_query.rb
praxis-mapper-3.1.1 lib/praxis-mapper/support/memory_query.rb