bountiful_blocks 1.1.0 → 1.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
  SHA256:
3
- metadata.gz: 107bca67d5b0f9fe089a8e67a701d349262fb64941d56b0cf8a721d0d99f0512
4
- data.tar.gz: 17bc58e18db0cdff78e8bcfe32b7bd4cb51d3b385a79a65d2cb0c40d4edac69b
3
+ metadata.gz: 67aa1f4e399b6e73e1b336b1c5c1bb93d11dd32f661fcaaa5f9c4436285dc75d
4
+ data.tar.gz: bf6ab6419e32e4bc6cab4859654afce4c968a5e1505469a8dc7cd626ab037970
5
5
  SHA512:
6
- metadata.gz: f53522d03a12b7b0aaa9ddd0536de017657ee4534da05c059a4248004bfe6f940e3437ffaee03af7641c7e9b43596818ae0d796fcff377e50444528331146628
7
- data.tar.gz: 8ecaca17d07af11ed7bd3cf31ace24d9cb808f40b6249d65bb21f4af0ee631ee9301658de034c05807d6f9a18b38c9f918ae4b57acf0eb651a940c604aac8e95
6
+ metadata.gz: a5f002cf969382785b756b1e04e62ca870b0d941a824875619666733ce0f708b4e6574d8c24122f582669a579dad0e82452db6381dc7c216be78cd45ffb93ace
7
+ data.tar.gz: f808fb510faceaf5c1e2aee72ac641cc34e985dca9919d5b7242500f33ab0a1fc3fa52ded5494ab4aa5a9b00a0bde010da6959930409b1cd4572745955d8b4ab
data/CHANGELOG.md CHANGED
@@ -8,6 +8,17 @@
8
8
  ### Bug fixes
9
9
  )-->
10
10
 
11
+ ## 1.1.1 2023-10-12
12
+
13
+ ### New features
14
+
15
+ - Added `given_blocks!` utility method.
16
+
17
+ ### Bug fixes
18
+
19
+ - The `given!` utility method was never filled during instantiation, now it works as described.
20
+ - Trying to invoke a block that was not passed now produces `NoMethodError` instead of `FrozenError`.
21
+
11
22
  ## 1.1.0 2023-09-07
12
23
 
13
24
  ### New features
data/README.md CHANGED
@@ -105,7 +105,8 @@ To avoid conflicts, all utility method names will end in either `!`, `?`, or `=`
105
105
  - `raw!` returns the value returned by the block, which can be useful to allow a block to work both as a regular block and a multiblock.
106
106
  - `given?(name)` returns `true` if a block named `name` was provided.
107
107
  - `given!` returns the names of all the provided blocks.
108
- - `call_all!` returns a Hash that maps all block names to their results. Notice that since multiblocks are frozen, `call_all!` can't cache the Hash and must create a new one on every invocation.
108
+ - `given_blocks!` returns all the provided blocks in a hash indexed by their names.
109
+ - `call_all!` returns a Hash that maps all block names to their results. You can provide arguments to `call_all!` and they will be forwarded in turn to all blocks. Notice that since multiblocks are frozen, `call_all!` can't cache the Hash and must create a new one on every invocation.
109
110
 
110
111
  ## Version numbers
111
112
 
@@ -7,7 +7,13 @@ module BountifulBlocks
7
7
 
8
8
  raise ArgumentError, "Block required for #{missing_blocks.join ', '}" unless missing_blocks.empty?
9
9
 
10
+ singleton_class.class_exec do
11
+ undef_method :method_missing
12
+ undef_method :respond_to_missing?
13
+ end
14
+
10
15
  given!.freeze
16
+ given_blocks!.freeze
11
17
  freeze
12
18
  end
13
19
 
@@ -16,6 +22,8 @@ module BountifulBlocks
16
22
  return super if name.end_with? '!', '?', '='
17
23
 
18
24
  define_singleton_method name, &block
25
+ given! << name
26
+ given_blocks![name] = block
19
27
 
20
28
  nil
21
29
  end
@@ -27,7 +35,7 @@ module BountifulBlocks
27
35
  end
28
36
 
29
37
  def given? name
30
- singleton_class.method_defined? name
38
+ given_blocks!.key? name
31
39
  end
32
40
 
33
41
  def given!
@@ -36,12 +44,18 @@ module BountifulBlocks
36
44
  @given
37
45
  end
38
46
 
47
+ def given_blocks!
48
+ @given_blocks = {} unless defined?(@given_blocks)
49
+
50
+ @given_blocks
51
+ end
52
+
39
53
  def raw!
40
54
  @raw
41
55
  end
42
56
 
43
- def call_all!
44
- given!.to_h { |name| [name, public_send(name)] }
57
+ def call_all!(*args, **kwargs, &block)
58
+ given_blocks!.transform_values { |given_block| given_block.call(*args, **kwargs, &block) }
45
59
  end
46
60
  end
47
61
  end
@@ -1,3 +1,3 @@
1
1
  module BountifulBlocks
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bountiful_blocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moku S.r.l.
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-09-07 00:00:00.000000000 Z
12
+ date: 2023-10-12 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A simple and idiomatic way to pass multiple blocks to a method.
15
15
  email:
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  requirements: []
55
- rubygems_version: 3.4.6
55
+ rubygems_version: 3.4.10
56
56
  signing_key:
57
57
  specification_version: 4
58
58
  summary: A simple and idiomatic way to pass multiple blocks to a method.