class ActiveRedis::QueryExecutor

Public Class Methods

execute(chainer) click to toggle source
# File lib/active_redis/query_executor.rb, line 4
def self.execute(chainer)
  ActiveRedis.connection.run_query_analyzer(chainer.target, prepare_params(chainer))
end

Private Class Methods

prepare_aggregation(aggregation) click to toggle source
# File lib/active_redis/query_executor.rb, line 27
def self.prepare_aggregation(aggregation)
  aggregation.inject("") {|str, (k, v)| str = "#{k}=#{v}" }
end
prepare_limit(limit) click to toggle source
# File lib/active_redis/query_executor.rb, line 23
def self.prepare_limit(limit)
  limit.any? ? "#{limit[:page]}=#{limit[:per_page]}" : ""
end
prepare_order(order) click to toggle source
# File lib/active_redis/query_executor.rb, line 18
def self.prepare_order(order)
  field = order.keys.first
  "#{field}=#{order[field]}"
end
prepare_params(chainer) click to toggle source
# File lib/active_redis/query_executor.rb, line 10
def self.prepare_params(chainer)
  [prepare_where(chainer.where_options), prepare_order(chainer.order_options), prepare_limit(chainer.limit_options), prepare_aggregation(chainer.aggregation_options)]
end
prepare_where(where) click to toggle source
# File lib/active_redis/query_executor.rb, line 14
def self.prepare_where(where)
  where.keys.map{|key| "#{key}=#{where[key]}" }.join(",")
end