README.md in service_it-0.1.6 vs README.md in service_it-0.2.0
- old
+ new
@@ -1,62 +1,63 @@
-# ServiceIt
+# ServiceIt [![Gem Version](https://badge.fury.io/rb/service_it.svg)](https://badge.fury.io/rb/service_it) [![Build Status](https://travis-ci.org/iago-silva/service_it.svg?branch=master)](https://travis-ci.org/iago-silva/service_it) [![Code Climate](https://codeclimate.com/github/iago-silva/service_it.png)](https://codeclimate.com/github/iago-silva/service_it) [![Downloads](https://img.shields.io/gem/dt/service_it.svg)](https://rubygems.org/gems/service_it) [![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
-[![Gem Version](https://badge.fury.io/rb/service_it.svg)](https://badge.fury.io/rb/service_it)
+Provide you a way to delegate responsibilities in your project using callables
-<div align="center">
- <img src="https://pbs.twimg.com/profile_images/1123677732/logo_avatar_large.png" height="250" width="250">
- <p>Its main objective is to provide you a way to delegate responsibilities in your project</p>
-</div>
-
<br/>
## Installation
Add this line to your application's Gemfile:
- gem 'service_it', '0.1.6'
+ gem 'service_it', '~> 0.1.6'
And then execute:
$ bundle
Or install it yourself as:
$ gem install service_it
+
+## Generator
+ $ rails g service NAME
+
## Usage
-Inherit your class of `Service` and implement `perform` method
```ruby
- class Foo < Service
- def perform
- # here you can use params that became instance variables
- end
+# app/services/foo.rb
+class Foo < ServiceIt::Base
+ def perform
+ # here you can use params that became instance variables
end
+end
```
Call your service from anywhere
```ruby
- Foo.call(params)
+Foo.call(params)
```
## Example
-Simple example to change status of a "transaction" to complete
+Simple example to change status of a _transaction_ to complete
+ $ rails g service CompleteTransaction
+
```ruby
- # app/services/complete_transation_service.rb
- class CompleteTransation < Service
- def perform
- @transation.update(:status, :complete)
- end
+# app/services/complete_transaction.rb
+class CompleteTransaction < ServiceIt::Base
+ def perform
+ @transaction.update(:status, :complete)
end
+end
```
```ruby
- if CompleteTransation.call(transation: @transation)
- puts 'Transation complete!'
- end
+if CompleteTransaction.call(transaction: transaction)
+ puts 'Transaction complete!'
+end
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/iago-silva/service_it.