micro_q 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/micro_q/methods/class.rb +0 -2
- data/lib/micro_q/methods/instance.rb +0 -2
- data/lib/micro_q/methods.rb +0 -23
- data/lib/micro_q/version.rb +1 -1
- data/spec/helpers/methods_examples.rb +0 -34
- data/spec/lib/methods/active_record_spec.rb +0 -6
- data/spec/lib/methods/class_spec.rb +0 -6
- data/spec/lib/methods/instance_spec.rb +0 -6
- metadata +1 -1
data/lib/micro_q/methods.rb
CHANGED
@@ -1,26 +1,3 @@
|
|
1
|
-
module MicroQ
|
2
|
-
module Methods
|
3
|
-
module SharedMethods
|
4
|
-
def method_missing(method, *other)
|
5
|
-
super unless /((.+)\_async$)/ === method
|
6
|
-
|
7
|
-
name = $2
|
8
|
-
|
9
|
-
# Define the method and call through.
|
10
|
-
if name && respond_to?(name)
|
11
|
-
define_singleton_method method do |*args|
|
12
|
-
async.send(name, *args)
|
13
|
-
end
|
14
|
-
|
15
|
-
async.send(name, *other)
|
16
|
-
else
|
17
|
-
super
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
1
|
# add Class and Instance methods first then
|
25
2
|
# override with additional extensions
|
26
3
|
require 'micro_q/methods/class'
|
data/lib/micro_q/version.rb
CHANGED
@@ -7,39 +7,5 @@ shared_examples_for "a_worker" do |method|
|
|
7
7
|
it 'should proxy to the object' do
|
8
8
|
subject.async.respond_to?(method).should == true
|
9
9
|
end
|
10
|
-
|
11
|
-
describe 'before first calling the _async method' do
|
12
|
-
it 'should not respond to the _async method' do
|
13
|
-
subject.respond_to?(method).should == true
|
14
|
-
subject.respond_to?("#{method}_async").should == false
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'after first call' do
|
19
|
-
before do
|
20
|
-
subject.send("#{method}_async")
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should add a _async method" do
|
24
|
-
subject.respond_to?(method).should == true
|
25
|
-
subject.respond_to?("#{method}_async").should == true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe 'errors' do
|
31
|
-
describe 'when calling a missing _async method' do
|
32
|
-
it 'should fail' do
|
33
|
-
expect {
|
34
|
-
subject.send("some_method_async")
|
35
|
-
}.to raise_error
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should raise an undefined method error (without the _async)' do
|
39
|
-
ex = (begin; subject.send("some_method_async"); rescue => e; e end)
|
40
|
-
|
41
|
-
ex.message.should match(/undefined method \`some_method_async\'/)
|
42
|
-
end
|
43
|
-
end
|
44
10
|
end
|
45
11
|
end
|
@@ -53,12 +53,6 @@ describe MicroQ::Methods::ActiveRecord, :active_record => true do
|
|
53
53
|
|
54
54
|
it_behaves_like 'a_worker', 'process'
|
55
55
|
|
56
|
-
describe 'when an _async method is called' do
|
57
|
-
let(:method) { lambda {|*args| subject.process_async(*args) } }
|
58
|
-
|
59
|
-
it_behaves_like 'an async AR instance'
|
60
|
-
end
|
61
|
-
|
62
56
|
describe 'when calling to async.method proxy' do
|
63
57
|
let(:method) { lambda {|*args| subject.async.process(*args) } }
|
64
58
|
|
@@ -47,12 +47,6 @@ describe MicroQ::Methods::Class do
|
|
47
47
|
|
48
48
|
it_behaves_like 'a_worker', 'seed'
|
49
49
|
|
50
|
-
describe 'when an _async method is called' do
|
51
|
-
let(:method) { lambda {|*args| subject.seed_async(*args) } }
|
52
|
-
|
53
|
-
it_behaves_like 'an async class'
|
54
|
-
end
|
55
|
-
|
56
50
|
describe 'when calling to async.method proxy' do
|
57
51
|
let(:method) { lambda {|*args| subject.async.seed(*args) } }
|
58
52
|
|
@@ -41,12 +41,6 @@ describe MicroQ::Methods::Instance do
|
|
41
41
|
|
42
42
|
it_behaves_like 'a_worker', 'process'
|
43
43
|
|
44
|
-
describe 'when an _async method is called' do
|
45
|
-
let(:method) { lambda {|*args| subject.process_async(*args) } }
|
46
|
-
|
47
|
-
it_behaves_like 'an async instance'
|
48
|
-
end
|
49
|
-
|
50
44
|
describe 'when calling to async.method proxy' do
|
51
45
|
let(:method) { lambda {|*args| subject.async.process(*args) } }
|
52
46
|
|