singleton_from 0.1.0 → 0.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: 14a78aa49192efa642fd39f412391cbb5954b8dd
4
- data.tar.gz: f389d4b073c6c96a8a2d2a3dff9198e04c343dbf
3
+ metadata.gz: 0f37220ea9a1f2f37624e2de541a7c77b1bdf3e4
4
+ data.tar.gz: a858f2ed49f437635c954ea412bd31fb0343898e
5
5
  SHA512:
6
- metadata.gz: 56382761cd2cc4d6f34f7f65a6d6ed4e8115cfb3cad7c353328bfa3d912c8eb7e63863928c054ed7d820e3b2ed47d65e8e94643d03970811ba5cfbd0816a89e9
7
- data.tar.gz: c61a0ba3d4d2d2105eafdf626d8e24b24b51178648e4ef95b80c1795aba900f857423696c5d0dd4e2661c1e498c788d410926e2a07193f6332dd21b8eee999ee
6
+ metadata.gz: 38c2b90c846a78edc9c721da7d31944408e99c59e07cfe3dfe0281d8132441f58cca279146807837efbfa5c763f6699a1b0b50c94f5a158d049691d1b8ef0296
7
+ data.tar.gz: bb3c156c0d45062f837fc91a43ae5ae7914c24f5348ab8793fded0f626037f40e83a9eb3956ad1758b5caa3bb7c1c7d01ffa89c83d7dabd7cf6d2a0ce6595c7b
data/README.md CHANGED
@@ -26,18 +26,22 @@ Or install it yourself as:
26
26
  class A
27
27
  singleton_from :start
28
28
 
29
- def initialize(arg1, arg2)
29
+ def initialize(arg1, arg2, &block)
30
+ p block.call
30
31
  p "Initialize"
31
32
  p arg1
32
33
  p arg2
33
34
  end
34
35
 
35
- def start
36
+ def start(&block)
36
37
  p "start"
38
+ p block.call
37
39
  end
38
40
  end
39
41
 
40
- A.start("1", "2")
42
+ A.start("1", "2") do
43
+ p "Hi, everyone... :-)"
44
+ end
41
45
  ```
42
46
 
43
47
  ## License
@@ -1,3 +1,3 @@
1
1
  module SingletonFrom
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -3,25 +3,29 @@ require "singleton_from/version"
3
3
  # class A
4
4
  # singleton_from :start
5
5
  #
6
- # def initialize(arg1, arg2)
6
+ # def initialize(arg1, arg2, &block)
7
+ # p block.call
7
8
  # p "Initialize"
8
9
  # p arg1
9
10
  # p arg2
10
11
  # end
11
12
  #
12
- # def start
13
+ # def start(&block)
14
+ # p block.call
13
15
  # p "start"
14
16
  # end
15
17
  # end
16
18
  #
17
- # A.start("1", "2")
19
+ # A.start("1", "2") do
20
+ # puts "Hi, everyone... :-)"
21
+ # end
18
22
 
19
23
  class Object
20
24
  class << self
21
25
  def singleton_from(method_name)
22
- self.class.send(:define_method, method_name) do |*args|
23
- instance = self.new(*args)
24
- instance.send(__method__)
26
+ self.class.send(:define_method, method_name) do |*args, &block|
27
+ instance = self.new(*args, &block)
28
+ instance.send(__method__, &block)
25
29
  end
26
30
  end
27
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: singleton_from
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gaëtan JUVIN