event-framework 1.0.4 → 1.0.5

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/event-framework.rb +17 -1
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5adb17a1332a1ccccc63ed51659bef8db4fea50d
4
- data.tar.gz: ad865e4a58c26a3808d5a324bdb1699ddc8cd18b
3
+ metadata.gz: 08ea584cdc07a46121cc42f48de72b45df0c3d6a
4
+ data.tar.gz: 7c46006e80b9acf330ab5ff81cc85e600227aa29
5
5
  SHA512:
6
- metadata.gz: e0871787ee6c1b2ec7ceee997c02960023a27f5892963f48f56c6f02d06c113c70425cdc4257341f17112134436e706e94653e1cce0e96386a44d5f3a7b9de0c
7
- data.tar.gz: 74104b04327d881a4a08479ca1b14f8437477dab45b1e5380325bca8def42e73f34dbc3c2b929dd1d3b8564bb9674b0fe9217dfc72045d9ce78304a99f2f42c4
6
+ metadata.gz: a89345595abf2fd2e9e85693eeb579e460bae744e81d7668315b32fd95424a70c47d5d8f9087ee18f3167df9af2e1c964e3dace8ed209568cfcb05a199434853
7
+ data.tar.gz: 0e021be365fd459e2d74afaec1b9e8b23beb09349aa7ae8127b356e74a9d822f37b85762b3d101bee4ddfdfbac281bb155eb08408812c9fa842620f3c5fb0af0
@@ -40,6 +40,7 @@
40
40
  # === Notices
41
41
  #
42
42
  # * EF::Object should be included after initialize
43
+ # * Also you may admix EF::Object methods and needed instance variables by extending: `Object.new.extend(EF::Object)`
43
44
  # * Callbacks will be executed in threads of subscribers (where they were defined)
44
45
  # * In the example the handler will be called in the main thread, <br> but if you define the client in the thread where you bind it to the server's event, <br> then the handler will be called in the same thread
45
46
  module EF
@@ -103,6 +104,10 @@ module EF
103
104
  ##
104
105
  # patches initialize to admix needed variables
105
106
  def self.included(base)
107
+ return if base.respond_to? :ef
108
+
109
+ def base.ef; end
110
+
106
111
  base.class_exec do
107
112
  alias alias_initialize initialize
108
113
 
@@ -121,6 +126,17 @@ module EF
121
126
  end
122
127
  end
123
128
 
129
+ ##
130
+ # allows you to extend any object
131
+ # obj = Object.new
132
+ # obj.extend EF::Object
133
+ def self.extended(base)
134
+ base.instance_variable_set :@mutex, Mutex.new
135
+ base.instance_variable_set :@thread, Thread.current
136
+ base.instance_variable_set :@observers, []
137
+ base.instance_variable_set :@observables, []
138
+ end
139
+
124
140
  ##
125
141
  # returns the thread where the object was defined
126
142
  def thread
@@ -186,7 +202,7 @@ module EF
186
202
  if (!observable || o == observable) && (!event || e == event) && (!block || b == block)
187
203
  if self == o
188
204
  @observers.reject! do |o, e, b|
189
- o == self && e == event && b == block
205
+ o == self
190
206
  end
191
207
  else
192
208
  o.unregistrate(self, e, b)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event-framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Speransky Danil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-05 00:00:00.000000000 Z
11
+ date: 2014-03-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Event Framework is a minimalistic library providing publish–subscribe
14
14
  pattern