Created
November 28, 2014 07:47
-
-
Save KamilLelonek/beab2991782684cf04c9 to your computer and use it in GitHub Desktop.
Service Object implementation skeleton
This file contains hidden or 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
class DoSomeAction | |
def initialize(dependency_injection_arguments) | |
# ... | |
end | |
def call(optional_arguments) | |
# ... | |
end | |
private | |
# a bunch of private methods | |
end |
This file contains hidden or 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
# regular execution | |
DoSomeAction.new.(arg1, arg2) | |
# with dependency injection | |
def do_some_action | |
DoSomeAction.new(http_adapter) | |
end | |
do_some_action.(arg1, arg2) | |
# in tests | |
let(:do_some_action) { DoSomeAction.new(fake_http_adapter) } | |
it { is_expected.to be_connected } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment