Skip to content

Instantly share code, notes, and snippets.

@lubekpl
Created October 13, 2017 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lubekpl/0530f912438f6a69b98833c642657128 to your computer and use it in GitHub Desktop.
Save lubekpl/0530f912438f6a69b98833c642657128 to your computer and use it in GitHub Desktop.
class ServiceGenerator < Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)
def copy_service_file
template "service.rb", "app/services/#{file_name}.rb"
end
def copy_service_spec_file
template "service_spec.rb", "spec/services/#{file_name}_spec.rb"
end
end
class <%= class_name %>
def initialize(*args)
end
def call
end
def self.call(*args)
new(args).call
end
private_class_method :new
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment