Sha256: 2e41bd85e5dab06ac911b9058cf31530ce83d2ba463b22107e91797fb1cbd9eb

Contents?: true

Size: 1001 Bytes

Versions: 6

Compression:

Stored size: 1001 Bytes

Contents

require_relative 'live_query'
require 'volt/utils/generic_pool'

class LiveQueryPool < GenericPool
  def initialize(data_store)
    super()
    @data_store = data_store
  end
  
  def lookup(collection, query)
    query = normalize_query(query)
    
    return super(collection, query)
  end
  
  def updated_collection(collection, skip_channel)
    lookup_all(collection).each do |live_query|
      # puts "RUN ON: #{live_query} with #{live_query.instance_variable_get('@channels').inspect}"
      live_query.run(skip_channel)
    end
  end
  
  private
    # Creates the live query if it doesn't exist, and stores it so it
    # can be found later.
    def create(collection, query)
      # If not already setup, create a new one for this collection/query
      return LiveQuery.new(self, @data_store, collection, query)
    end
  
    def normalize_query(query)
      # TODO: add something to sort query properties so the queries are
      # always compared the same.
      return query
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
volt-0.6.5 app/volt/tasks/live_query/live_query_pool.rb
volt-0.6.4 app/volt/tasks/live_query/live_query_pool.rb
volt-0.6.3 app/volt/tasks/live_query/live_query_pool.rb
volt-0.6.2 app/volt/tasks/live_query/live_query_pool.rb
volt-0.6.1 app/volt/tasks/live_query/live_query_pool.rb
volt-0.6.0 app/volt/tasks/live_query/live_query_pool.rb