From f392e380fb4a6dc0c1f2df377136510b1bb6db26 Mon Sep 17 00:00:00 2001 From: Erica Porter Date: Thu, 25 Apr 2024 12:27:40 +0100 Subject: [PATCH] Fix for service pattern namespacing issue --- lib/dfe/analytics/shared/service_pattern.rb | 38 ++++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/dfe/analytics/shared/service_pattern.rb b/lib/dfe/analytics/shared/service_pattern.rb index 3f2f28c0..cade2197 100644 --- a/lib/dfe/analytics/shared/service_pattern.rb +++ b/lib/dfe/analytics/shared/service_pattern.rb @@ -1,23 +1,27 @@ -# a template for creating service objects -module ServicePattern - def self.included(base) - base.extend(ClassMethods) - base.class_eval do - private_class_method(:new) - end - end +module DfE + module Analytics + # a template for creating service objects + module ServicePattern + def self.included(base) + base.extend(ClassMethods) + base.class_eval do + private_class_method(:new) + end + end - def call - raise(NotImplementedError('#call must be implemented')) - end + def call + raise(NotImplementedError('#call must be implemented')) + end - # provides class-level methods to the classes that include ServicePattern - # defines a template for the `call` method; the expected entry point for service objects - module ClassMethods - def call(*args, **keyword_args, &block) - return new.call if args.empty? && keyword_args.empty? && block.nil? + # provides class-level methods to the classes that include ServicePattern + # defines a template for the `call` method; the expected entry point for service objects + module ClassMethods + def call(*args, **keyword_args, &block) + return new.call if args.empty? && keyword_args.empty? && block.nil? - new(*args, **keyword_args, &block).call + new(*args, **keyword_args, &block).call + end + end end end end