Last active
March 18, 2019 01:53
-
-
Save lxbrito/49b1bcb3d269c9b4382da824614a584b to your computer and use it in GitHub Desktop.
ActiveBusiness Service implementation example
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
# frozen_string_literal: true | |
# :nodoc: | |
class YourActiveBusinessImplementation < ActiveBusiness | |
attr_reader :arg | |
def self.call(arg) | |
new(arg).call | |
end | |
def initialize(arg) | |
super() | |
self.arg = arg | |
end | |
def call | |
return resolve_to(:nothing_changed).call if arg.nil? | |
if arg == 'x' | |
resolve_to(:sucess).call(some_object_instance) | |
else | |
resolve_to(:error).call('Arg should really be x') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment