callwith 0.0.1 → 0.0.2
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.
- data/ext/callwith_ext.c +3 -3
- data/lib/callwith.rb +7 -3
- metadata +3 -3
data/ext/callwith_ext.c
CHANGED
@@ -64,8 +64,8 @@ void Init_with_ext()
|
|
64
64
|
rb_undef_alloc_func(rb_cCallWith);
|
65
65
|
rb_define_singleton_method(rb_cCallWith, "create", callwith_s_create, 2);
|
66
66
|
rb_define_method(rb_cCallWith, "__instance_eval__", rb_obj_instance_eval, -1);
|
67
|
-
rb_define_method(rb_cCallWith, "
|
68
|
-
rb_define_method(rb_cCallWith, "
|
69
|
-
rb_define_method(rb_cCallWith, "
|
67
|
+
rb_define_method(rb_cCallWith, "__callwith__obj__", callwith_obj, 0);
|
68
|
+
rb_define_method(rb_cCallWith, "__callwith__self_obj__", callwith_self_obj, 0);
|
69
|
+
rb_define_method(rb_cCallWith, "__callwith__cleanup__", callwith_cleanup, 0);
|
70
70
|
}
|
71
71
|
|
data/lib/callwith.rb
CHANGED
@@ -15,15 +15,19 @@ def callwith(*objs, &block)
|
|
15
15
|
last = nil
|
16
16
|
objs.each do |obj|
|
17
17
|
p = CallWith.create(obj, self)
|
18
|
-
|
18
|
+
begin
|
19
|
+
last = p.__instance_eval__(&block)
|
20
|
+
ensure
|
21
|
+
p.__callwith__cleanup__()
|
22
|
+
end
|
19
23
|
end
|
20
24
|
return last
|
21
25
|
end
|
22
26
|
|
23
27
|
class CallWith
|
24
28
|
def method_missing(method, *args, &block)
|
25
|
-
obj =
|
26
|
-
self_obj =
|
29
|
+
obj = __callwith__obj__()
|
30
|
+
self_obj = __callwith__self_obj__()
|
27
31
|
|
28
32
|
if obj.respond_to?(method)
|
29
33
|
obj.__send__(method, *args, &block)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: callwith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Paul Brannan
|