SimpleOperation
The idea behind SimpleOperation is to provide a very basic class creator that facilitates using service objects.
Installation
Add this line to your application's Gemfile:
gem 'simple_operation'
And then execute:
$ bundle
Or install it yourself as:
$ gem install simple_operation
Usage
Example usage for SimpleOperation is creating user:
class CreateUser < SimpleOperation.new(:login, :password)
def call
user = User.new(login, password)
validate_user(user)
UserRepository.persist(user)
user
end
private
def validate_user(user)
!UserRepository.fetch_all_logins.include?(user.login)
end
end
CreateUser.('Grzegorz', '[email protected]')
Contributing
- Fork it ( https://github.com/[my-github-username]/simple_operation/fork )
- 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 a new Pull Request