attr_extras 7.0.0 → 7.1.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
  SHA256:
3
- metadata.gz: e5fd3ea490025e4ed3942658efff5b14335b261d843dead16fedd3f75fe9ca2c
4
- data.tar.gz: 1adcf6c8e345de200ba9d0798caa4d996a62fb76ebcbe4ad2d167a996e98dacd
3
+ metadata.gz: 466f80d1e0d81139ee5eeb996a584fb26b7ae69062e5bce75a901095e1b3ff82
4
+ data.tar.gz: a8e7b0a9ef95e1375d5a928d65f0c76371c8796c1cca813a4c27a897e32cadbb
5
5
  SHA512:
6
- metadata.gz: ba168966ed66c2369fd23e1a11505ea06b0c559ce874492ec9744240505d6fbc3af2a13fc91b0e4ed4b51ff0768fd67c51fb24b6ed2ae5181fe71194ce304159
7
- data.tar.gz: 37696980e733441e426e0102e2e8473b61206ef95be7a761197d5ed41571f2ead7304313a8c49d810b00eed4f21b485be1b0011ef3e5aa77a2efdde32852a598
6
+ metadata.gz: 68c0d15374bd6a9a3eeaecd3d7b7458ed874e99f05927ac3a07b2c9d6d11c63d7c230347191eb1c06d2501fca387cb032c5d67e580422833afb4967bdc09fb74
7
+ data.tar.gz: c1012ecd9b537608b382eec96a8a449fc85d8f32dd2ad6380ae6a246cf5d44d3b61c00a7c8be21b32a7a0f4d22afcf7c7a0ca0870877a84dbb587c433b6355e6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [7.1.0](https://github.com/barsoom/attr_extras/releases/tag/v7.1.0)
4
+
5
+ - Make `static_facade` and `method_object` take a block for initalization.
6
+
3
7
  ## [7.0.0](https://github.com/barsoom/attr_extras/releases/tag/v7.0.0)
4
8
 
5
9
  - Drop end-of-lifed Ruby 2.5 and 2.6.
@@ -60,7 +60,7 @@ module AttrExtras
60
60
 
61
61
  alias_method :attr_accessor_initialize, :aattr_initialize
62
62
 
63
- def static_facade(method_name_or_names, *names)
63
+ def static_facade(method_name_or_names, *names, &block)
64
64
  if names.any? { |name| name.is_a?(Array) }
65
65
  Array(method_name_or_names).each do |method_name|
66
66
  define_singleton_method(method_name) do |*args, **opts, &block|
@@ -75,11 +75,11 @@ module AttrExtras
75
75
  end
76
76
  end
77
77
 
78
- pattr_initialize(*names)
78
+ pattr_initialize(*names, &block)
79
79
  end
80
80
 
81
- def method_object(*names)
82
- static_facade :call, *names
81
+ def method_object(*names, &block)
82
+ static_facade :call, *names, &block
83
83
  end
84
84
 
85
85
  def attr_query(*names)
@@ -1,3 +1,3 @@
1
1
  module AttrExtras
2
- VERSION = "7.0.0"
2
+ VERSION = "7.1.0"
3
3
  end
@@ -26,6 +26,20 @@ describe Object, ".method_object" do
26
26
  assert klass.call
27
27
  end
28
28
 
29
+ it "accepts a block for initialization" do
30
+ klass = Class.new do
31
+ method_object :value do
32
+ @copy = @value
33
+ end
34
+
35
+ attr_reader :copy
36
+ end
37
+
38
+ example = klass.new("expected")
39
+
40
+ _(example.copy).must_equal "expected"
41
+ end
42
+
29
43
  it "passes along any block" do
30
44
  klass = Class.new do
31
45
  method_object
@@ -45,6 +45,20 @@ describe Object, ".static_facade" do
45
45
  assert klass.barable?(false)
46
46
  end
47
47
 
48
+ it "accepts a block for initialization" do
49
+ klass = Class.new do
50
+ static_facade :foo, :value do
51
+ @copy = @value
52
+ end
53
+
54
+ attr_reader :copy
55
+ end
56
+
57
+ example = klass.new("expected")
58
+
59
+ _(example.copy).must_equal "expected"
60
+ end
61
+
48
62
  it "passes along any block to the instance method" do
49
63
  klass = Class.new do
50
64
  static_facade :foo
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0
4
+ version: 7.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2022-11-10 00:00:00.000000000 Z
15
+ date: 2023-02-09 00:00:00.000000000 Z
16
16
  dependencies: []
17
17
  description:
18
18
  email:
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
- rubygems_version: 3.3.20
82
+ rubygems_version: 3.4.3
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Takes some boilerplate out of Ruby with methods like attr_initialize.