module Services

Constants

NoBackgroundProcessorFound
RedisNotFound
VERSION

Public Class Methods

allow_class_method_in_queries(klass, method, arity = nil) click to toggle source
# File lib/services.rb, line 22
def allow_class_method_in_queries(klass, method, arity = nil)
  (configuration.allowed_class_methods_in_queries[klass.to_s] ||= {})[method.to_sym] = arity
end
redis() click to toggle source
# File lib/services.rb, line 18
def redis
  @redis ||= configuration.redis || (defined?(Redis.current) && Redis.current) or fail RedisNotFound, 'Redis not configured.'
end
replace_global_ids_with_records(arg) click to toggle source
# File lib/services.rb, line 37
def replace_global_ids_with_records(arg)
  method = method(__method__)

  case arg
  when Array  then arg.map(&method)
  when Hash   then arg.transform_keys(&method)
                      .transform_values(&method)
  when String then (arg.starts_with?("_") && GlobalID::Locator.locate(arg[1..-1])) || arg
  else arg
  end
end
replace_records_with_global_ids(arg) click to toggle source
# File lib/services.rb, line 26
def replace_records_with_global_ids(arg)
  method = method(__method__)

  case arg
  when Array then arg.map(&method)
  when Hash  then arg.transform_keys(&method)
                     .transform_values(&method)
  else arg.respond_to?(:to_global_id) ? "_#{arg.to_global_id.to_s}" : arg
  end
end