Skip to content

Instantly share code, notes, and snippets.

@lxbrito
Last active March 18, 2019 01:53
Show Gist options
  • Save lxbrito/49b1bcb3d269c9b4382da824614a584b to your computer and use it in GitHub Desktop.
Save lxbrito/49b1bcb3d269c9b4382da824614a584b to your computer and use it in GitHub Desktop.
ActiveBusiness Service implementation example
# 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