ServiceGenerator can generate a class of service
Add this line to your application's Gemfile:
gem 'service_generator', github: 'rawhide/service_generator'
And then execute:
$ bundle
When you have ServiceGenerator installed and generate a service...
rails generate service example
The following files are created.
app/services/example_service.rb
spec/services/example_service_spec.rb
class ExampleService < BaseService
attr_accessor :active_flag
def execute
something...
end
end
result = ExampleService.new(params).authorized_by(current_user).with_options(token: 'abc').invoke
if result.success?
something...
else
something...
end
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request