nakajima-booty-call 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/booty_call/hook.rb +3 -1
- data/lib/booty_call/introspector.rb +1 -1
- data/lib/booty_call/observed_method.rb +2 -2
- data/lib/booty_call.rb +1 -1
- metadata +1 -1
data/lib/booty_call/hook.rb
CHANGED
@@ -5,6 +5,7 @@ module BootyCall
|
|
5
5
|
extend(ClassMethods)
|
6
6
|
@callbacker = BootyCall::Callbacker.new(self)
|
7
7
|
@introspector = BootyCall::Introspector.new(self)
|
8
|
+
@meta_introspector = BootyCall::Introspector.new(self, :meta => true)
|
8
9
|
end
|
9
10
|
end
|
10
11
|
|
@@ -18,7 +19,8 @@ module BootyCall
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def observe(method_id, options={}, &block)
|
21
|
-
|
22
|
+
observer = options[:meta] ? @meta_introspector : @introspector
|
23
|
+
observer.observe(method_id, options, &block)
|
22
24
|
end
|
23
25
|
|
24
26
|
def callback(position, method_id, *args, &block)
|
@@ -10,7 +10,7 @@ module BootyCall
|
|
10
10
|
def observe_klass!
|
11
11
|
@observed ||= begin
|
12
12
|
this = self
|
13
|
-
hook = options[:
|
13
|
+
hook = options[:meta] ? :singleton_method_added : :method_added
|
14
14
|
klass.meta_def(hook) do |m|
|
15
15
|
this.check_method(m)
|
16
16
|
end; true
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module BootyCall
|
2
2
|
class ObservedMethod
|
3
3
|
attr_reader :method_id
|
4
|
-
|
4
|
+
|
5
5
|
def initialize(method_id, options={})
|
6
6
|
@method_id = method_id
|
7
7
|
@callbacks = []
|
@@ -20,7 +20,7 @@ module BootyCall
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def valid?
|
23
|
-
@times.
|
23
|
+
@times.to_s.match(/^(inf|any|all|every)/) or @count < @times
|
24
24
|
end
|
25
25
|
|
26
26
|
def push(*args)
|
data/lib/booty_call.rb
CHANGED