callbacks_attachable 1.1.1 → 1.2.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
  SHA1:
3
- metadata.gz: f22cf5eb5888489ce9faaebb66fd204af4850fd5
4
- data.tar.gz: d91062df946227799e0e122011687c1a8216a46a
3
+ metadata.gz: 81a1654f014d9e55c862d04cddc2220b77d08fc2
4
+ data.tar.gz: 38e878bb95354ecbc13fcae519e8a35dc70c0779
5
5
  SHA512:
6
- metadata.gz: a1503eca8d080d495b979480e55f3ecd783b3ead85a3abd941e8c34176b3f745fa9a0d27fa27dd6d9b48424d9b38418b6de6071c1f8ea155e5144911ec0b2d43
7
- data.tar.gz: c6ec51d1f9a1464265c6992c10154c70f838819119b9c641e3d103a018c4912cfee3cf16f2e44688cdd3488d34f041d1a104668b2e9a1a1f04ddab60a99798ce
6
+ metadata.gz: 41df492f40cc6746035513c53a4e503d647359db01bd3b88697eb324b258a5d500178b90a26db91ecff10e4ee4b3814a7fed0f2b5f4df16cf4c907714f4e3fae
7
+ data.tar.gz: 9dc191acaa137a6478b245039b7586c7ca30d73ebbfce741207ff64e4105078d54bc0075223f4f4315af37cab71837aac1882437de343c699a3f90aebc34e3d3
@@ -11,10 +11,10 @@ particular instance. Additionally, instances can also have their own set of
11
11
  individual callbacks.
12
12
  DESC
13
13
 
14
- spec.homepage = "https://github.com/christopheraue/ruby-callbacks_attachable"
14
+ spec.homepage = "https://github.com/christopheraue/m-ruby-callbacks_attachable"
15
15
  spec.license = "MIT"
16
16
  spec.authors = ["Christopher Aue"]
17
- spec.email = "rubygems@christopheraue.net"
17
+ spec.email = ["rubygems@christopheraue.net"]
18
18
 
19
19
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
data/mrbgem.rake CHANGED
@@ -8,7 +8,8 @@ Attach callbacks to a class and trigger them for all its instances or just one
8
8
  particular instance. Additionally, instances can also have their own set of
9
9
  individual callbacks.
10
10
  DESC
11
- spec.homepage = "https://github.com/christopheraue/ruby-callbacks_attachable"
11
+
12
+ spec.homepage = "https://github.com/christopheraue/m-ruby-callbacks_attachable"
12
13
  spec.license = 'MIT'
13
14
  spec.authors = ['Christopher Aue']
14
15
 
@@ -3,12 +3,13 @@ module CallbacksAttachable
3
3
  def initialize(object, callback_class)
4
4
  @object = object
5
5
  @callback_class = callback_class
6
+ @callbacks = {}
6
7
  end
7
8
 
8
9
  def on(event, opts = {}, &callback)
9
- __callbacks__[event] ||= []
10
- __callbacks__[event] << @callback_class.new(@object, opts, &callback)
11
- __callbacks__[event].last
10
+ @callbacks[event] ||= []
11
+ @callbacks[event] << @callback_class.new(@object, opts, &callback)
12
+ @callbacks[event].last
12
13
  end
13
14
 
14
15
  def once_on(event, *opts, &callback)
@@ -29,22 +30,16 @@ module CallbacksAttachable
29
30
  end
30
31
 
31
32
  def trigger(instance, event, args)
32
- return true if __callbacks__[event].nil?
33
+ return true unless @callbacks[event]
33
34
 
34
35
  # dup the callback list so that removing callbacks while iterating does
35
36
  # still call all callbacks during map.
36
- __callbacks__[event].dup.all?{ |callback| callback.call(instance, args) }
37
+ @callbacks[event].dup.all?{ |callback| callback.call(instance, args) }
37
38
  end
38
39
 
39
40
  def off(event, callback)
40
- return unless __callbacks__[event]
41
- __callbacks__[event].delete(callback)
42
- end
43
-
44
- private
45
-
46
- def __callbacks__
47
- @__callbacks__ ||= {}
41
+ return unless @callbacks[event]
42
+ @callbacks[event].delete(callback)
48
43
  end
49
44
  end
50
45
  end
@@ -29,8 +29,6 @@ module CallbacksAttachable
29
29
  end
30
30
  alias trigger_event trigger
31
31
 
32
- private
33
-
34
32
  def __callback_registry__
35
33
  @__callback_registry__ ||= CallbackRegistry.new(self, AllInstancesCallback)
36
34
  end
@@ -57,7 +55,7 @@ module CallbacksAttachable
57
55
  alias off_event off
58
56
 
59
57
  def trigger(event, *args)
60
- self.class.__send__(:__callback_registry__).trigger(self, event, args) and __callback_registry__.trigger(self, event, args)
58
+ self.class.__callback_registry__.trigger(self, event, args) and __callback_registry__.trigger(self, event, args)
61
59
  end
62
60
  alias trigger_event trigger
63
61
 
data/mrblib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CallbacksAttachable
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callbacks_attachable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Aue
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-12 00:00:00.000000000 Z
11
+ date: 2016-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,7 +56,8 @@ description: |
56
56
  Attach callbacks to a class and trigger them for all its instances or just one
57
57
  particular instance. Additionally, instances can also have their own set of
58
58
  individual callbacks.
59
- email: rubygems@christopheraue.net
59
+ email:
60
+ - rubygems@christopheraue.net
60
61
  executables: []
61
62
  extensions: []
62
63
  extra_rdoc_files: []
@@ -74,7 +75,7 @@ files:
74
75
  - mrblib/callbacks_attachable.rb
75
76
  - mrblib/instance_callback.rb
76
77
  - mrblib/version.rb
77
- homepage: https://github.com/christopheraue/ruby-callbacks_attachable
78
+ homepage: https://github.com/christopheraue/m-ruby-callbacks_attachable
78
79
  licenses:
79
80
  - MIT
80
81
  metadata: {}