service_it 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cd3980a2426fb7838e0ae392a4a12a79ea81d0a385eae6fd5b53e3147f02f11
4
- data.tar.gz: 4bef1fceed1af00155948b3399da13cee01b24ca65ad77dbfb8a6ac92df3165f
3
+ metadata.gz: f3f5602ec47b3704b58581e2367192e409ff098a3232f25d925cf1256f82d434
4
+ data.tar.gz: a9c85fe22387bcca449b0242905f204e2b30473c6259246cf345341c549712f5
5
5
  SHA512:
6
- metadata.gz: 017467fd53746def423e3456badf5a0ac6e7ff896489738b9015a5b83cca12718a13355de5489f6b28282bc05ab7cb85d7b1266a12ceedc50c8db724c4f06a9d
7
- data.tar.gz: ce95f14007a1dbbcd1aae0c1186e6c79852f037f4e4fb4fa5c8d8cefd371855cbb6c9b45e96648a7988af46256c8284c5b35ff59e22217fb6e39c84bf237f94a
6
+ metadata.gz: df4426ddc277a66097a73e40228e722fffcb69c9e114041143936f1c377fa98d440651bacf4f20d8a06e62fff1a2a769bcd66395657aa959ad7b5a47c64aa9ff
7
+ data.tar.gz: 2d356875f6f388617705b4b8f6799a616a8046553385f3c0da94b087f4b077d1dbf7bba7e43792fe495aa1e89040c067a8351f0dae19ee74190d3cb3beb4151c
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # ServiceIt
2
2
  [![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) [![Test Coverage](https://api.codeclimate.com/v1/badges/fcc8375ebe8fa5412381/test_coverage)](https://codeclimate.com/github/iago-silva/service_it/test_coverage)
3
3
 
4
+ Its benefit is to facilitate the creation of Service Objects, providing you the basic and enough to have a complete one and letting you free to use on your own way.
5
+
4
6
  - [ServiceIt](#serviceit)
5
7
  - [Installation](#installation)
6
8
  - [With Bundler](#with-bundler)
@@ -16,7 +18,7 @@
16
18
 
17
19
  Add this line to your `Gemfile`:
18
20
 
19
- gem 'service_it', '~> 1.0.0'
21
+ gem 'service_it', '~> 1.2.0'
20
22
 
21
23
  And then execute:
22
24
 
@@ -6,38 +6,22 @@ module ServiceIt
6
6
  # Documentation:
7
7
  # https://github.com/iago-silva/service_it
8
8
  class Base
9
- class << self
10
- # Call your service
11
- #
12
- # Example:
13
- # Foo.call(arg1: 1, arg2: 2)
14
- #
15
- # Arguments:
16
- # args: (Hash)
17
- #
18
- # Return:
19
- # perform's return
20
- def call(**args)
21
- new_instance(args).perform
22
- end
23
-
24
- private
25
-
26
- def new_instance(args)
27
- instance = new
28
-
29
- args.each do |key, value|
30
- instance.instance_variable_set("@#{key}", value)
31
-
32
- class_eval do
33
- private
34
-
35
- attr_accessor key.to_sym
36
- end
37
- end
9
+ # Call your service
10
+ #
11
+ # Example:
12
+ # Foo.call(arg1: 1, arg2: 2)
13
+ #
14
+ # Arguments:
15
+ # args: (Hash)
16
+ #
17
+ # Return:
18
+ # perform's return
19
+ def self.call(**args)
20
+ new(args).perform
21
+ end
38
22
 
39
- instance
40
- end
23
+ def initialize(args)
24
+ args.each { |key, value| set_private_ivar(key, value) }
41
25
  end
42
26
 
43
27
  # Implement this method to run your service
@@ -45,5 +29,17 @@ module ServiceIt
45
29
  raise NotImplementedError,
46
30
  "Please implement 'perform' method in your #{self.class.name}"
47
31
  end
32
+
33
+ private
34
+
35
+ def set_private_ivar(key, value)
36
+ instance_variable_set("@#{key}", value)
37
+
38
+ self.class.class_eval do
39
+ private
40
+
41
+ attr_reader key.to_sym
42
+ end
43
+ end
48
44
  end
49
45
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ServiceIt
4
- VERSION = '1.1.0'.freeze
4
+ VERSION = '1.2.0'.freeze
5
5
  end
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ServiceIt do
4
6
  describe SayMyName do
5
7
  let(:name) { 'Heisenberg' }
6
- let(:call) { SayMyName.call(name: 'Heisenberg') }
7
8
 
8
9
  it 'says Heisenberg' do
9
- expect(call).to eq(name)
10
+ result = SayMyName.call(name: name)
11
+ expect(result).to eq(name)
10
12
  end
11
13
  end
12
14
 
@@ -1,12 +1,13 @@
1
- require 'simplecov'
2
-
3
- SimpleCov.minimum_coverage 100
4
- SimpleCov.start do
5
- add_filter '/spec/'
6
- end
1
+ # frozen_string_literal: true
7
2
 
8
3
  $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
9
4
 
10
5
  require 'service_it'
6
+ require 'simplecov'
11
7
 
12
8
  Dir['./spec/support/**/*.rb'].each { |f| require f }
9
+
10
+ SimpleCov.minimum_coverage 100
11
+ SimpleCov.start do
12
+ add_filter '/spec/'
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: service_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iago Silva