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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee142231055e893f34d726e7bbf57b5fd27da851e49c63a5a33a3dcf6a000abe
4
- data.tar.gz: 5ca62a10c247a02435622b8190114f45c8e28be50f9a5e8e8dd5f21c42a99c2c
3
+ metadata.gz: 20e65a3bddc28ca3121413e665f084f096c7b266304d9c486bc2d7c9b618ab8a
4
+ data.tar.gz: 455304b5999249cd475f5df8a44e0d855333ccf208f41d9cd98c7cfe1bba3cac
5
5
  SHA512:
6
- metadata.gz: c8bb160a235375a6a99c2c379413b79952ac85492211feb08dc77e0435e7e87aef3edc5c68bed81b16364a5197615321ea3a894c6bbad9143c831fb63f781fdd
7
- data.tar.gz: c861884ac244f036a9ab78edce25cf857fed41afcf18467354dd784e27728921b3a6c61695cbbf86ae3d0bef2ad71a2364e84bed2d9b6f6f33d27bae810ab0cf
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.fetch(:actions) { hash.fetch(:action) }] if hash.is_a?(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(observer, options = Utils::EMPTY_HASH)
26
- if options[:allow_duplication] || !included?(observer)
27
- @list << [:observer, observer, options[:data]]
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(observer)
44
- @list.delete_if(&EqualTo[observer])
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
@@ -1,5 +1,5 @@
1
1
  module Micro
2
2
  module Observers
3
- VERSION = '0.6.0'
3
+ VERSION = '0.7.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: u-observers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Serradura