rectify 0.10.0 → 0.11.0

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: 765fc6e3fd9b5d66f59f4a5c2b279f2eae06a5d7
4
- data.tar.gz: 41379b062e59c2be3be9507565704dc230b0191b
3
+ metadata.gz: 023c7446586e45b59dd33434b3e6e28ff2b1b124
4
+ data.tar.gz: 8effed228976a4180eca21bba19a07890bf6e7c3
5
5
  SHA512:
6
- metadata.gz: dfefaa5dd1fb1954cfabf1a1e86f5469c60c6329a8037ad99461ba375a5e1d80ec20ebf8a367c8647e10a86c895f04ee9a34fc6f9dc7c9bc6cd5dd7d0e5a31f1
7
- data.tar.gz: 8936f106a590145d25c12c661e337c0e906b5fefc81b7ac42eb7d2ef4ad14e4a54f121d8c5ccfd1879aa8b2f97d3e820ff37eb47449facf0d68808178aff453d
6
+ metadata.gz: 20248a82b7b065da5f78248c399dab6c1b32960c92054560ba455c783bce50758239a8eafb646b03e2851197ed06ddbfce8b868ef27269933ba496e13b5e37d5
7
+ data.tar.gz: bf4b24b64e8f52d3d682b2ce027a9a7cd05becaef676708340556a5a2a8e357fb24bef0b1e88559441c248a5c22c95af994e4a7bf7e067f977b0ce0a9354e5f5
@@ -18,7 +18,7 @@ module Rectify
18
18
 
19
19
  private
20
20
 
21
- attr_reader :form_class, :form, :model
21
+ attr_reader :form_class, :model
22
22
 
23
23
  def form
24
24
  @form ||= form_class.new
@@ -1,15 +1,39 @@
1
1
  module Rectify
2
+ class EventRecorder
3
+ attr_reader :events
4
+
5
+ def initialize
6
+ @events = {}
7
+ end
8
+
9
+ # rubocop:disable Style/MethodMissing
10
+ def method_missing(method_name, *args, &_block)
11
+ args = args.first if args.size == 1
12
+ @events[method_name] = args
13
+ end
14
+ # rubocop:enable Style/MethodMissing
15
+
16
+ def respond_to_missing?(_method_name, _include_private = false)
17
+ true
18
+ end
19
+ end
20
+
2
21
  class Command
3
22
  include Wisper::Publisher
4
23
 
5
24
  def self.call(*args, &block)
25
+ event_recorder = EventRecorder.new
26
+
6
27
  command = new(*args)
28
+ command.subscribe(event_recorder)
7
29
  command.evaluate(&block) if block_given?
8
30
  command.call
31
+
32
+ event_recorder.events
9
33
  end
10
34
 
11
35
  def evaluate(&block)
12
- @caller = eval("self", block.binding)
36
+ @caller = eval("self", block.binding, __FILE__, __LINE__)
13
37
  instance_eval(&block)
14
38
  end
15
39
 
@@ -1,3 +1,3 @@
1
1
  module Rectify
2
- VERSION = "0.10.0".freeze
2
+ VERSION = "0.11.0".freeze
3
3
  end
data/readme.md CHANGED
@@ -609,6 +609,29 @@ When an event is handled, the appropriate block is called in the context of the
609
609
  controller. Basically, any method call within the block is delegated back to the
610
610
  controller.
611
611
 
612
+ As well as capturing events in a block, the command will also return a hash of the
613
+ broadcast events together with any parameters that were passed. For example:
614
+
615
+ ```ruby
616
+ events = RegisterAccount.call(form)
617
+
618
+ events # => { :ok => user }
619
+ ```
620
+
621
+ There will be a key for each event broadcast and its value will be the parameters
622
+ passed. If there is a single parameter it will be the value. If there are no
623
+ parameters or many, the hash value for the event key will be an array of the parameters:
624
+
625
+ ```ruby
626
+ events = RegisterAccount.call(form)
627
+
628
+ events # => {
629
+ # :ok => user,
630
+ # :messages => ["User registered", "Email sent", "Account ready"],
631
+ # :next => []
632
+ # }
633
+ ```
634
+
612
635
  You may occasionally want to expose a value within a handler block to the view.
613
636
  You do this via the `expose` method within the handler block. If you want to
614
637
  use `expose` then you must include the `Rectify::ControllerHelpers` module in
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rectify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Pike
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-01 00:00:00.000000000 Z
11
+ date: 2018-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: virtus
14
+ name: activemodel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.5
19
+ version: 4.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.5
26
+ version: 4.1.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: wisper
28
+ name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.6.1
33
+ version: 4.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.6.1
40
+ version: 4.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,33 +53,33 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: 4.1.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: activemodel
56
+ name: virtus
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 4.1.0
61
+ version: 1.0.5
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 4.1.0
68
+ version: 1.0.5
69
69
  - !ruby/object:Gem::Dependency
70
- name: activerecord
70
+ name: wisper
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 4.1.0
75
+ version: 1.6.1
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 4.1.0
82
+ version: 1.6.1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: actionpack
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -123,49 +123,49 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.10.3
125
125
  - !ruby/object:Gem::Dependency
126
- name: rspec
126
+ name: rake
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: '3.4'
131
+ version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: '3.4'
138
+ version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: rspec-collection_matchers
140
+ name: rspec
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '1.1'
145
+ version: '3.4'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '1.1'
152
+ version: '3.4'
153
153
  - !ruby/object:Gem::Dependency
154
- name: sqlite3
154
+ name: rspec-collection_matchers
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ">="
157
+ - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '0'
159
+ version: '1.1'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ">="
164
+ - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '0'
166
+ version: '1.1'
167
167
  - !ruby/object:Gem::Dependency
168
- name: rake
168
+ name: rubocop
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
@@ -179,7 +179,7 @@ dependencies:
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
- name: rubocop
182
+ name: sqlite3
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - ">="