# 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) Provide you a way to delegate responsibilities in your project using callables
## Installation Add this line to your application's Gemfile: 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 ```ruby # 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) ``` ## Example Simple example to change status of a _transaction_ to complete $ rails g service CompleteTransaction ```ruby # app/services/complete_transaction.rb class CompleteTransaction < ServiceIt::Base def perform @transaction.update(:status, :complete) end end ``` ```ruby 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. ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).