rietveld 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f831ee5bab34effe5e45935530fa692b5148d03
4
- data.tar.gz: 7249be7df3e42e3a8cc62872ea36c3ec8dfad061
3
+ metadata.gz: ac3e2eb52b3a53b32027a8eab25b6307737d5eb2
4
+ data.tar.gz: c8ccea1342c286f00a12fc65a77f41a61d35d5b7
5
5
  SHA512:
6
- metadata.gz: 5bb4ddb9985c21de6e899c26f6f2e4f6f2dbeb383bf73a65bd9490612a04292c5eaed5fe36c555ca267d7621877dee9a2443f53055eebc13fdf49895666f86f7
7
- data.tar.gz: fa16fccfea98bc912b3601b6862ab6edec15369d15b72bb04fdc3060c5944bbb31b1d36311df7ad86b9307f30dac6ac726eacd53a6bf145ab97aaab62ecbef53
6
+ metadata.gz: b60efac74b799d93b86244d220ab46099e67698496714570a245ec5dd90c39a438932748eef08ad8aa5cbe6bb88f1412401c56743c7844fd9805a058987fe5a3
7
+ data.tar.gz: 3382f09d51a3ae6b71fae879b0212d862343b34e520b04fd64a8a59bddc2a1512779aaf8b5f2b601b3d1f7264b28e75632b38b8e5fdef6648eade4c382dbf473
data/README.md CHANGED
@@ -11,3 +11,35 @@ And then execute:
11
11
  Or install it yourself as:
12
12
 
13
13
  $ gem install rietveld
14
+
15
+
16
+ ## Example
17
+
18
+ ``` ruby
19
+ class MoneyTransferContext < Rietveld::Context
20
+ role :source_account do
21
+ def withdraw(amount)
22
+ if balance >= amount
23
+ decrease_balance(amount)
24
+ amount
25
+ else
26
+ raise 'Insufficient funds'
27
+ end
28
+ end
29
+
30
+ def transfer(amount)
31
+ destination_account.deposit(withdraw(amount))
32
+ end
33
+ end
34
+
35
+ role :destination_account do
36
+ def deposit(amount)
37
+ increase_balance(amount)
38
+ end
39
+ end
40
+
41
+ def transfer(amount)
42
+ source_account.transfer(amount)
43
+ end
44
+ end
45
+ ```
@@ -1,4 +1,38 @@
1
- module Rietveld
1
+ module Rietveld # :nodoc:
2
+
3
+ ##
4
+ # The Context class supplies a simple DSL for creating roles and interaction
5
+ # between those roles
6
+ #
7
+ # An example:
8
+ #
9
+ # class MoneyTransferContext < Rietveld::Context
10
+ # role :source_account do
11
+ # def withdraw(amount)
12
+ # if balance >= amount
13
+ # decrease_balance(amount)
14
+ # amount
15
+ # else
16
+ # raise 'Insufficient funds'
17
+ # end
18
+ # end
19
+ #
20
+ # def transfer(amount)
21
+ # destination_account.deposit(withdraw(amount))
22
+ # end
23
+ # end
24
+ #
25
+ # role :destination_account do
26
+ # def deposit(amount)
27
+ # increase_balance(amount)
28
+ # end
29
+ # end
30
+ #
31
+ # def transfer(amount)
32
+ # source_account.transfer(amount)
33
+ # end
34
+ # end
35
+ #
2
36
  class Context
3
37
  class << self
4
38
  def roles
@@ -1,3 +1,3 @@
1
1
  module Rietveld
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rietveld
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Schilstra