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.
Files changed (3) hide show
  1. data/ext/callwith_ext.c +3 -3
  2. data/lib/callwith.rb +7 -3
  3. metadata +3 -3
@@ -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, "__with__obj__", callwith_obj, 0);
68
- rb_define_method(rb_cCallWith, "__with__self_obj__", callwith_self_obj, 0);
69
- rb_define_method(rb_cCallWith, "__with__cleanup__", callwith_cleanup, 0);
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
 
@@ -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
- last = p.__instance_eval__(&block)
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 = __with__obj__()
26
- self_obj = __with__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: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul Brannan