Skip to content

Instantly share code, notes, and snippets.

@oinak
Created October 25, 2016 13:39
Show Gist options
  • Select an option

  • Save oinak/d77205b17857862f3e309e2e5be21dd0 to your computer and use it in GitHub Desktop.

Select an option

Save oinak/d77205b17857862f3e309e2e5be21dd0 to your computer and use it in GitHub Desktop.
# to be called:
# ExampleService[1, {some: 'opt'}]
class ExampleService < Services::Base
# customize your setup
def initialize(concrete, arguments = {})
@concrete = concrete
@arguments = arguments
end
# customize your processing
def call
end
end
module Services
class Base
class << self
def call
new(*args).call
end
alias_method :[], :call
end
private_class_method :new
# to be customized on subclases
def call
raise NotImplementedError
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment