Skip to content

Instantly share code, notes, and snippets.

@KamilLelonek
Created November 28, 2014 07:47
Show Gist options
  • Save KamilLelonek/beab2991782684cf04c9 to your computer and use it in GitHub Desktop.
Save KamilLelonek/beab2991782684cf04c9 to your computer and use it in GitHub Desktop.
Service Object implementation skeleton
class DoSomeAction
def initialize(dependency_injection_arguments)
# ...
end
def call(optional_arguments)
# ...
end
private
# a bunch of private methods
end
# 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