resugan 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: b0c94f2885b44f9105e0f6bc738947aa41cdb29e
4
- data.tar.gz: aa688b92c3fb9542685f00f0121ae274fcd605aa
3
+ metadata.gz: 06266abd04e9aecee4b5a28654d177b0e2780dfd
4
+ data.tar.gz: ff5a9e7c6a3bd73fe07c6572796aca4006812b11
5
5
  SHA512:
6
- metadata.gz: a7dd76bc32c30971518858f3106a23edc2ad8c198c762aaf9b6cfded67079d0fbeef2a2f81fc701593493f0ef94cc75dee7587f9b66ab2d4062313b88ac6c848
7
- data.tar.gz: a513e050ea06afa69a81cb8627076688d27808e4149a5e3d5713af09d69bc6ff449170672b46b68c66d409800e0745c6fff8e91b4554fd20fad8af53929c7a68
6
+ metadata.gz: e0465ac0358fb465cf1ccf2388d466c48a080eb0586362a313a3d9b4c701992fda770da3e3d835e74231ed9fb5c83b5914e7669c7b44c614444e5274e1aa2853
7
+ data.tar.gz: 50d00661a3f35779bbda13d26fc86483fce997764fe987f0f0a2ea7ea72c3c8baf6e26815a182e8fd0bfdceb5196fcaf739bf47267d403bc298bfef86841277a
@@ -16,10 +16,8 @@ module Resugan
16
16
  end
17
17
 
18
18
  def invoke
19
- @events.each do |k,v|
20
- puts "fire #{k}"
21
- Resugan::Kernel.invoke(@namespace, k, v)
22
- end
19
+ dispatcher = Resugan::Kernel.dispatcher_for(@namespace)
20
+ dispatcher.dispatch(@namespace, @events)
23
21
  end
24
22
  end
25
23
  end
@@ -0,0 +1,11 @@
1
+ module Resugan
2
+ module Engine
3
+ class InlineDispatcher
4
+ def dispatch(namespace, events)
5
+ events.each do |k,v|
6
+ Resugan::Kernel.invoke(namespace, k, v)
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,15 @@
1
1
  module Resugan
2
2
  class Kernel
3
+ def self.dispatcher_for(namespace = '')
4
+ @dispatchers = {} unless @dispatchers
5
+ @dispatchers[namespace] || Resugan::Engine::InlineDispatcher.new
6
+ end
7
+
8
+ def self.register_dispatcher(dispatcher, namespace = '')
9
+ @dispatchers = {} unless @dispatchers
10
+ @dispatchers[namespace] = dispatcher
11
+ end
12
+
3
13
  def self.register(event, block)
4
14
  register_with_namespace("", event, block)
5
15
  end
@@ -20,7 +30,6 @@ module Resugan
20
30
 
21
31
  def self.invoke(namespace, event, payload = [])
22
32
  event = "#{namespace}_#{event}".to_sym
23
- p payload
24
33
  if @listener[event]
25
34
  @listener[event].each do |listener|
26
35
  listener.call(payload.map { |p| p[:params] })
@@ -1,3 +1,3 @@
1
1
  module Resugan
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/resugan.rb CHANGED
@@ -4,6 +4,7 @@ require "resugan/object"
4
4
  require "resugan/thread"
5
5
  require "resugan/context"
6
6
  require "resugan/object_helpers"
7
+ require "resugan/engine/inline_dispatcher"
7
8
 
8
9
  module Resugan
9
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resugan
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
  - Joseph Emmanuel Dayo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-13 00:00:00.000000000 Z
11
+ date: 2016-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,6 +85,7 @@ files:
85
85
  - bin/setup
86
86
  - lib/resugan.rb
87
87
  - lib/resugan/context.rb
88
+ - lib/resugan/engine/inline_dispatcher.rb
88
89
  - lib/resugan/kernel.rb
89
90
  - lib/resugan/object.rb
90
91
  - lib/resugan/object_helpers.rb