lowevent 0.8.3 → 0.8.4
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 +4 -4
- data/lib/events/request_event.rb +3 -1
- data/lib/interfaces/definable.rb +5 -1
- data/lib/interfaces/event.rb +5 -3
- data/lib/version.rb +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 989b25ac44f0c670523b30724bd57c58615138bdff5f89848624d321960b0a94
|
|
4
|
+
data.tar.gz: 44266265ece187faa0d6949142844965bcdd88f251855f3b00655ce59d8be01c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e515767eda84dec79878b5f65e106ca074234ae25dba362ea787943a5a78bc81aff26c17acaff8175a2ab6dce049741ac72717314408ba15441e2c551f5153e4
|
|
7
|
+
data.tar.gz: ece6d5f87350060d8378e3373a0d0b80b4878d94331fc58682fd22951fcdca53ea54f8616d70bce47037c684b5bc096faa74798062069dad8df8c65c8e160fe5
|
data/lib/events/request_event.rb
CHANGED
|
@@ -4,11 +4,13 @@ require_relative '../interfaces/event'
|
|
|
4
4
|
|
|
5
5
|
module Low
|
|
6
6
|
module Events
|
|
7
|
+
# A request, which its first observer to respond answers. On the response's way back out, each observer it passed
|
|
8
|
+
# with a "response" method gets "response(event:, result:)", with the response it took, and can add to it.
|
|
7
9
|
class RequestEvent < Event
|
|
8
10
|
attr_reader :request
|
|
9
11
|
|
|
10
12
|
def initialize(request:, action: :request)
|
|
11
|
-
super(key: self.class, action:)
|
|
13
|
+
super(key: self.class, action:, return_action: :response)
|
|
12
14
|
|
|
13
15
|
@request = request
|
|
14
16
|
end
|
data/lib/interfaces/definable.rb
CHANGED
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
module Low
|
|
4
4
|
module Events
|
|
5
5
|
module Definable
|
|
6
|
+
# Yields the event's observers to add to. A block that returns a list puts them in that order, so an observer can
|
|
7
|
+
# go first: "observers = [MyLogger, *observers]".
|
|
6
8
|
def define(key = self)
|
|
7
|
-
|
|
9
|
+
observers = observers(key)
|
|
10
|
+
list = yield observers
|
|
11
|
+
observers.replace(list) if list.is_a?(Array)
|
|
8
12
|
end
|
|
9
13
|
|
|
10
14
|
class << self
|
data/lib/interfaces/event.rb
CHANGED
|
@@ -22,15 +22,17 @@ module Low
|
|
|
22
22
|
include Events::Definable
|
|
23
23
|
include Support::ValueObject
|
|
24
24
|
|
|
25
|
-
attr_reader :key, :action, :actions, :created_at
|
|
25
|
+
attr_reader :key, :action, :actions, :return_action, :created_at
|
|
26
26
|
attr_accessor :children
|
|
27
27
|
|
|
28
28
|
# Subclass provides a key such as "self.class".
|
|
29
29
|
# Subclass defines default action or actions, but not both.
|
|
30
|
-
|
|
30
|
+
# A return action, like :response, is called on each observer a take passed, with what it took, on its way back out.
|
|
31
|
+
def initialize(key:, action: nil, actions: [], return_action: nil, children: [])
|
|
31
32
|
@key = key
|
|
32
33
|
@action = action
|
|
33
34
|
@actions = actions
|
|
35
|
+
@return_action = return_action
|
|
34
36
|
@children = children
|
|
35
37
|
|
|
36
38
|
@created_at = Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
|
|
@@ -45,7 +47,7 @@ module Low
|
|
|
45
47
|
def take
|
|
46
48
|
event_tree = branch
|
|
47
49
|
key = Observers::Keys[@key]
|
|
48
|
-
key.take(event: self) { restore_level(event_tree:) }
|
|
50
|
+
key.take(event: self, returning: @return_action) { restore_level(event_tree:) }
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
def branch
|
data/lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lowevent
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- maedi
|
|
@@ -27,16 +27,22 @@ dependencies:
|
|
|
27
27
|
name: observers
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '1.1'
|
|
30
33
|
- - ">="
|
|
31
34
|
- !ruby/object:Gem::Version
|
|
32
|
-
version:
|
|
35
|
+
version: 1.1.1
|
|
33
36
|
type: :runtime
|
|
34
37
|
prerelease: false
|
|
35
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
39
|
requirements:
|
|
40
|
+
- - "~>"
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '1.1'
|
|
37
43
|
- - ">="
|
|
38
44
|
- !ruby/object:Gem::Version
|
|
39
|
-
version:
|
|
45
|
+
version: 1.1.1
|
|
40
46
|
- !ruby/object:Gem::Dependency
|
|
41
47
|
name: protocol-http
|
|
42
48
|
requirement: !ruby/object:Gem::Requirement
|