attr_extras 5.1.0 → 5.2.0

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: e7b11dd2ebaf3539d9762cf9563f38e916a4e034
4
- data.tar.gz: 3163edce22740e67ff4baf9aa69912b6406bbae1
3
+ metadata.gz: 31be8de6a1c2dbbb19e44ea4255d099e656728b3
4
+ data.tar.gz: f5a8e9dbfdef34e1f1d368c889ae7a0f825e07e2
5
5
  SHA512:
6
- metadata.gz: 78abb1acb59bc72c5801bbcece4b27669006b2844bd7a461b3ca84359c52a9d7e20f3406cfe26dfb672f703e7867b7b72a19fe81972bcfce88133341b17d34d6
7
- data.tar.gz: e6dee11b104ae7f18fb50d5855e49ba5a910d75270d3dd611aaa38210fd5dcae8400ec0654f338b3e2e6f6bdd564c88ca1df66857f5f4717ae592310e4453c71
6
+ metadata.gz: 30d562066800bdcc69011c4eb7ed26966d61aae06e4ebd1050ba7346bb15ef1b131edaa547f2aec9504f61ef103c9022126c40a2ebdd12bf4838d3b8722f387d
7
+ data.tar.gz: 4ba342974d86d1c4d0d3eeb30d41caa1fa97720b4626e7bbbafe7245fbf5dd48c4a10ef52c7ce8a43d3f2557a9c7ccb19218c2c21fc94e711fe31a7918958f32
data/README.md CHANGED
@@ -229,6 +229,8 @@ You don't have to specify arguments/readers if you don't want them: just `static
229
229
 
230
230
  You can specify multiple method names as long as they can share the same initializer arguments: `static_facade [:allow?, :deny?], :user, [:user_agent, :ip!]`
231
231
 
232
+ Any block given to the class method will be passed on to the instance method.
233
+
232
234
  "Static façade" is the least bad name for this pattern we've come up with. Suggestions are welcome.
233
235
 
234
236
 
@@ -290,6 +292,8 @@ end
290
292
 
291
293
  You don't have to specify arguments/readers if you don't want them: just `method_object` is also valid.
292
294
 
295
+ Any block given to the class method will be passed on to the instance method.
296
+
293
297
 
294
298
  ### `attr_implement`
295
299
 
@@ -63,8 +63,8 @@ module AttrExtras
63
63
 
64
64
  def static_facade(method_name_or_names, *names)
65
65
  Array(method_name_or_names).each do |method_name|
66
- define_singleton_method(method_name) do |*values|
67
- new(*values).public_send(method_name)
66
+ define_singleton_method(method_name) do |*values, &block|
67
+ new(*values).public_send(method_name, &block)
68
68
  end
69
69
  end
70
70
 
@@ -1,3 +1,3 @@
1
1
  module AttrExtras
2
- VERSION = "5.1.0"
2
+ VERSION = "5.2.0"
3
3
  end
@@ -78,5 +78,4 @@ describe Object, ".cattr_implement" do
78
78
 
79
79
  lambda { klass.foo }.must_raise ArgumentError
80
80
  end
81
-
82
81
  end
@@ -25,4 +25,16 @@ describe Object, ".method_object" do
25
25
 
26
26
  assert klass.call
27
27
  end
28
+
29
+ it "passes along any block" do
30
+ klass = Class.new do
31
+ method_object
32
+
33
+ def call
34
+ yield
35
+ end
36
+ end
37
+
38
+ assert klass.call { :foo } == :foo
39
+ end
28
40
  end
@@ -44,4 +44,16 @@ describe Object, ".static_facade" do
44
44
  assert klass.fooable?(true)
45
45
  assert klass.barable?(false)
46
46
  end
47
+
48
+ it "passes along any block to the instance method" do
49
+ klass = Class.new do
50
+ static_facade :foo
51
+
52
+ def foo
53
+ yield
54
+ end
55
+ end
56
+
57
+ assert klass.foo { :bar } == :bar
58
+ end
47
59
  end
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: 5.1.0
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-10-25 00:00:00.000000000 Z
13
+ date: 2017-01-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: minitest
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  requirements: []
115
115
  rubyforge_project:
116
- rubygems_version: 2.5.1
116
+ rubygems_version: 2.5.2
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: Takes some boilerplate out of Ruby with methods like attr_initialize.