octiron 0.1.0 → 0.1.1

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: 0a1d5d04db3e10eb26f3292976922347550a8174
4
- data.tar.gz: 609b4ac6d312fc78d74bbe3d3a127cc937584798
3
+ metadata.gz: 336926004fffc1105bb354c76c1e5435d95b27fc
4
+ data.tar.gz: 9d6efe5638f209dfabf38062969b72dc0ce71ec6
5
5
  SHA512:
6
- metadata.gz: 8783e03aa012d7b3049ea7824b00a8699d94ac703ee1506bc6bd9e080367506aebc022e060fa6099a565620ce3146d808743adb5585cbac152271baec5b0471b
7
- data.tar.gz: b0d09e6f7d9336fb965272a7d2d66264f1e698377563acd4988472c95901959b8434a8fa20ac757a1dda3b0f5129842db7e7454ff1fe414dbd575f9ac6ea6f01
6
+ metadata.gz: 05c58fdb427c609711728fb4f965a7e5a86cebe5ccac9d8f87043e1921c690562f775c0a14fb3204b7dc9b4a6d33fc6c2ddbad2999352aa2b5966d353193089a
7
+ data.tar.gz: fbec63c5c3956741db10a49445503aa8892d77956e3139e9539749b06e6b524998dc91e30992ec26f9b272b35d923537753b34ebdfcd4bbaed8a7708e57b5ac7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- octiron (0.1.0)
4
+ octiron (0.1.1)
5
5
  collapsium (~> 0.8)
6
6
  rgl (~> 0.5)
7
7
 
@@ -50,7 +50,7 @@ GEM
50
50
  simplecov-html (~> 0.10.0)
51
51
  simplecov-html (0.10.0)
52
52
  stream (0.5)
53
- unicode-display_width (1.1.1)
53
+ unicode-display_width (1.1.2)
54
54
  yard (0.9.5)
55
55
 
56
56
  PLATFORMS
data/README.md CHANGED
@@ -27,6 +27,8 @@ class MyEvent
27
27
  # ...
28
28
  end
29
29
 
30
+ include Octiron::World
31
+
30
32
  on_event(MyEvent) do |event|
31
33
  # event.is_a?(MyEvent) == true
32
34
  # do something with the event
@@ -41,12 +41,9 @@ module Octiron::Events
41
41
  # must be provided.
42
42
  # @return The class represented by the event_id, as a String name.
43
43
  def subscribe(event_id, handler_object = nil, &handler_proc)
44
- handler = resolve_handler(handler_object, &handler_proc)
45
- event_name = identify(event_id)
46
-
47
- handlers_for(event_name, true) << handler
48
-
49
- return event_name
44
+ return with_handlers(event_id, handler_object, handler_proc) do |hlist, h|
45
+ hlist << h
46
+ end
50
47
  end
51
48
  alias register subscribe
52
49
 
@@ -62,12 +59,9 @@ module Octiron::Events
62
59
  # must be provided.
63
60
  # @return The class represented by the event_id, as a String name.
64
61
  def unsubscribe(event_id, handler_object = nil, &handler_proc)
65
- handler = resolve_handler(handler_object, &handler_proc)
66
- event_name = identify(event_id)
67
-
68
- handlers_for(event_name, true).delete(handler)
69
-
70
- return event_name
62
+ return with_handlers(event_id, handler_object, handler_proc) do |hlist, h|
63
+ hlist.delete(h)
64
+ end
71
65
  end
72
66
 
73
67
  ##
@@ -148,6 +142,15 @@ module Octiron::Events
148
142
  return @handlers[name] || []
149
143
  end
150
144
 
145
+ def with_handlers(event_id, handler_object, handler_proc)
146
+ handler = resolve_handler(handler_object, &handler_proc)
147
+ event_name = identify(event_id)
148
+
149
+ yield handlers_for(event_name, true), handler
150
+
151
+ return event_name
152
+ end
153
+
151
154
  def resolve_handler(handler_object = nil, &handler_proc)
152
155
  handler = handler_proc || handler_object
153
156
  if not handler
@@ -8,5 +8,5 @@
8
8
  #
9
9
  module Octiron
10
10
  # The current release version
11
- VERSION = "0.1.0".freeze
11
+ VERSION = "0.1.1".freeze
12
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octiron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Finkhaeuser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-08 00:00:00.000000000 Z
11
+ date: 2016-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler