Class: Volt::DataStore::BaseAdaptorClient

Inherits:
Object
  • Object
show all
Defined in:
lib/volt/data_stores/base_adaptor_client.rb

Class Method Summary collapse

Class Method Details

.data_store_methods(*method_names) ⇒ Object

A class method that takes an array of method names we want to provide on the ArrayModel class. (These are typically query/sort/order/etc… methods). This adds a proxy method to the store persistor for all passed in method names, and then sets up a default tracking method on the ArrayStore persistor.



23
24
25
26
27
28
29
30
31
# File 'lib/volt/data_stores/base_adaptor_client.rb', line 23

def self.data_store_methods(*method_names)
  Volt::ArrayModel.proxy_to_persistor(*method_names)

  method_names.each do |method_name|
    Volt::Persistors::ArrayStore.send(:define_method, method_name) do |*args|
      add_query_part(method_name, *args)
    end
  end
end

.normalize_query(query) ⇒ Object

normalize_query should take all parts of the query and return a “normalized” version, so that two queries that are eseitnally the same except for things like order are the same.

Typically this means sorting parts of the query so that two queries which do the same things are the same, so they can be uniquely identified.

The default implementation does no normalizing. This works, but results in more queries being sent to the backend.



14
15
16
# File 'lib/volt/data_stores/base_adaptor_client.rb', line 14

def self.normalize_query(query)
  query
end