-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for service pattern namespacing issue (#137)
- Loading branch information
1 parent
1ef5b2d
commit 8278e9c
Showing
1 changed file
with
21 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |