u-observers 0.6.0 → 0.7.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.
- checksums.yaml +4 -4
- data/lib/micro/observers/events_or_actions.rb +1 -1
- data/lib/micro/observers/manager.rb +11 -5
- data/lib/micro/observers/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20e65a3bddc28ca3121413e665f084f096c7b266304d9c486bc2d7c9b618ab8a
|
4
|
+
data.tar.gz: 455304b5999249cd475f5df8a44e0d855333ccf208f41d9cd98c7cfe1bba3cac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fe33fb9bc6bcb060f32329e28774abb6a7b546e178e531d045043889db64c403afd00171351e733df33cc812e84763c9aaf47f89c82dc6cd37264ab8ba8fd04
|
7
|
+
data.tar.gz: af195ddbdacb7e811f8c30d45d389d4b9472df7d06966009740e8cf4400676add7d80cda18db166795fafe27ae82277ed1930a2c72053bf427f4fefe424c37bc
|
@@ -13,7 +13,7 @@ module Micro
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.fetch_actions(hash)
|
16
|
-
return self[hash
|
16
|
+
return self[hash[:actions] || hash.fetch(:action)] if hash.is_a?(Hash)
|
17
17
|
|
18
18
|
raise ArgumentError, 'expected a hash with the key :action or :actions'
|
19
19
|
end
|
@@ -22,9 +22,13 @@ module Micro
|
|
22
22
|
@list.any?(&EqualTo[observer])
|
23
23
|
end
|
24
24
|
|
25
|
-
def attach(
|
26
|
-
|
27
|
-
|
25
|
+
def attach(*args)
|
26
|
+
options = args.last.is_a?(Hash) ? args.pop : Utils::EMPTY_HASH
|
27
|
+
|
28
|
+
Utils.compact_array(args).each do |observer|
|
29
|
+
if options[:allow_duplication] || !included?(observer)
|
30
|
+
@list << [:observer, observer, options[:data]]
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
self
|
@@ -40,8 +44,10 @@ module Micro
|
|
40
44
|
@list << [:callable, event, [callable, arg]]
|
41
45
|
end
|
42
46
|
|
43
|
-
def detach(
|
44
|
-
|
47
|
+
def detach(*args)
|
48
|
+
Utils.compact_array(args).each do |observer|
|
49
|
+
@list.delete_if(&EqualTo[observer])
|
50
|
+
end
|
45
51
|
|
46
52
|
self
|
47
53
|
end
|