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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31be8de6a1c2dbbb19e44ea4255d099e656728b3
|
4
|
+
data.tar.gz: f5a8e9dbfdef34e1f1d368c889ae7a0f825e07e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/lib/attr_extras/explicit.rb
CHANGED
@@ -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
|
|
data/lib/attr_extras/version.rb
CHANGED
@@ -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.
|
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:
|
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.
|
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.
|