sagas 0.0.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/sagas.rb +34 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1e5859e7cd5a7b7d6d1915eed8608da28a886b98
4
+ data.tar.gz: 367e2e85ca6887c0f468c060afff260e5a2316c3
5
+ SHA512:
6
+ metadata.gz: 0ed5ac2dda86a88a044e03a762e45a8ca124f557921e3d951e8ad238eb1918134a07dc034825f799796a71997a9236f9a9d4fa3ca78ee23137eb4ea9ee88b403
7
+ data.tar.gz: 5a01d5c032624d41baf2de0878fa9472ca7a6f1fae4a15f0d7c97cf021143ed876b43f76ce562195941dea4473830e64bf08519b1311f0d90f01a404f130a4e6
data/lib/sagas.rb ADDED
@@ -0,0 +1,34 @@
1
+ class Effect
2
+ def initialize(name, transaction, compensation)
3
+ @name = name
4
+
5
+ (class << self; self; end).class_eval do
6
+ define_method :transaction do
7
+ transaction.call
8
+ end
9
+
10
+ define_method :compensation do
11
+ compensation.call
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ class Saga
18
+ attr_reader :actions
19
+
20
+ def initialize()
21
+ @actions = []
22
+ end
23
+
24
+ def run(action)
25
+ action.transaction
26
+ @actions.push(action)
27
+ end
28
+
29
+ def abort
30
+ actions.each do |action|
31
+ action.compensation
32
+ end
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sagas
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Victor Yu
8
+ - Arjun Lall
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2018-11-30 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Boop
15
+ email: victor.yu.canada@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/sagas.rb
21
+ homepage: http://rubygems.org/gems/sagas
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.5.2
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: A Ruby implementation of Sagas
45
+ test_files: []