Module: Services
- Includes:
- GemConfig::Base
- Defined in:
- lib/services.rb,
lib/services/base.rb,
lib/services/query.rb,
lib/services/railtie.rb,
lib/services/version.rb,
lib/services/asyncable.rb,
lib/services/logger/file.rb,
lib/services/logger/null.rb,
lib/services/logger/redis.rb,
lib/services/modules/call_logger.rb,
lib/services/modules/object_class.rb,
lib/services/modules/exception_wrapper.rb,
lib/services/modules/uniqueness_checker.rb
Defined Under Namespace
Modules: Asyncable, Logger, ObjectClass
Classes: Base, Query, Railtie
Constant Summary
collapse
- NoBackgroundProcessorFound =
Class.new(StandardError)
- RedisNotFound =
Class.new(StandardError)
- VERSION =
'9.0.0'.freeze
Class Method Summary
collapse
Class Method Details
.allow_class_method_in_queries(klass, method, arity = nil) ⇒ Object
22
23
24
|
# 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 ⇒ Object
18
19
20
|
# 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) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
|
# 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) ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# 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
|