simple_service 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -10
- data/lib/simple_service/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34986961f7123b9e3d467a2886eac29975e5ca1c
|
4
|
+
data.tar.gz: 69ef5d5fd27746e2f9cd3ef1fdebf8ca1052f9b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de14c40b0a186d035b1a7c1a8b43a4e9d6ac7c00209bccde3f7200661f816baeba28c2b4d94875b95c98122bc95433b9d991367c226ae5ca92f6ef7f7d778d13
|
7
|
+
data.tar.gz: 6946d0168b295ff890883a2c7fb966fc5b0214441581712fbc5f785dbb2c999387dc45db49d8e7cd9e12e3564c127012438551049e9069b2dadbd748b925f6ea
|
data/README.md
CHANGED
@@ -7,8 +7,9 @@
|
|
7
7
|
SimpleService gives you a way to organize service objects such that they adhere
|
8
8
|
to the single responsibility principle. Instead of writing large service objects
|
9
9
|
that perform multiple tasks, SimpleService allows you to breakdown tasks into a
|
10
|
-
set
|
11
|
-
|
10
|
+
set of sequentially performed "Command" objects. Commands are very small classes
|
11
|
+
that perform exactly one task. When properly designed, these command
|
12
|
+
objects can be reused in multiple organizers minimizing code duplication.
|
12
13
|
|
13
14
|
When an organizer is instantiated a hash of arguments is passed in. This hash
|
14
15
|
is referred to as the context. The context hash is carried along throughout
|
@@ -17,13 +18,16 @@ successful run, the entire context hash (or a specified subset) is returned.
|
|
17
18
|
|
18
19
|
First, setup an Organizer class. An Organizer needs the following things defined:
|
19
20
|
|
20
|
-
* expects: keys that are required to be passed into initialize when an
|
21
|
-
of organizer is created. If not defined the organizer will
|
22
|
-
|
23
|
-
*
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
* expects: keys that are required to be passed into initialize when an
|
22
|
+
instance of organizer is created. If not defined the organizer will
|
23
|
+
accept arbitrary arguments.
|
24
|
+
* returns: keys that will be returned when the organizer has executed all of
|
25
|
+
its commands
|
26
|
+
* commands: classes that define all the steps that the organizer will execute.
|
27
|
+
The organizer will call #execute on each command in order and the context
|
28
|
+
hash is passed to each of these commands. Any keys within the context that
|
29
|
+
are modified will be merged back into the organizer and passed along to the
|
30
|
+
next command.
|
27
31
|
|
28
32
|
```ruby
|
29
33
|
class ProcessSomethingComplex < SimpleService::Organizer
|
@@ -102,7 +106,8 @@ not using rails, a similar structure would also be recommended.
|
|
102
106
|
|
103
107
|
## Inspiration and Rationale
|
104
108
|
|
105
|
-
This gem is heavily inspired by two very nice gems:
|
109
|
+
This gem is heavily inspired by two very nice gems:
|
110
|
+
[mutations](https://github.com/cypriss/mutations) and
|
106
111
|
[light-service](https://github.com/adomokos/light-service).
|
107
112
|
|
108
113
|
Mutations is a great gem, but lacks the concept of a top level organizer.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarrod Spillers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|