async_methods 1.0.0 → 1.0.1

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/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{async_methods}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian Durand"]
12
- s.date = %q{2010-06-22}
12
+ s.date = %q{2010-06-24}
13
13
  s.description = %q{Gem that adds asynchronous method calls for all methods on every object to aid in throughput on I/O bound processes. This is intended to improve throughput on I/O bound processes like making several HTTP calls in row.}
14
14
  s.email = %q{brian@embellishedvisions.com}
15
15
  s.extra_rdoc_files = [
@@ -11,14 +11,15 @@ module AsyncMethods
11
11
 
12
12
  # Override missing method to add the async method handling
13
13
  def method_missing_with_async (method, *args, &block)
14
- if method.to_s[0, 6] == 'async_'
14
+ method = method.to_s
15
+ if method[0, 6] == 'async_'
15
16
  method = method.to_s
16
- return Proxy.new(self, method[6 , method.length].to_sym, args, &block)
17
+ return Proxy.new(self, method[6 , method.length], args, &block)
17
18
  else
18
19
  # Keep track of the current missing method calls to keep out of an infinite loop
19
20
  stack = Thread.current[:async_method_missing_methods] ||= []
20
21
  sig = MethodSignature.new(self, method)
21
- raise NoMethodError.new("undefined method `#{method}' for #{self}") if stack.include?(sig)
22
+ raise NoMethodError.new("undefined method `#{method}' for #{self.inspect}") if stack.include?(sig)
22
23
  begin
23
24
  stack.push(sig)
24
25
  return method_missing_without_async(method, *args, &block)
@@ -53,12 +54,12 @@ module AsyncMethods
53
54
  # The proxy object does all the heavy lifting.
54
55
  class Proxy
55
56
  # These methods we don't want to override. All other existing methods will be redefined.
56
- PROTECTED_METHODS = %w(initialize __proxy_result__ __proxy_loaded__ method_missing)
57
+ PROTECTED_METHODS = %w(initialize __proxy_result__ __proxy_loaded__ method_missing __send__ object_id)
57
58
 
58
59
  def initialize (obj, method, args = [], &block)
59
60
  # Override already defined methods on Object to proxy them to the result object
60
61
  methods.each do |m|
61
- eval "def self.#{m} (*args, &block); __proxy_result__.send(:#{m}, *args, &block); end" unless PROTECTED_METHODS.include?(m)
62
+ eval "def self.#{m} (*args, &block); __proxy_result__.send(:#{m}, *args, &block); end" unless PROTECTED_METHODS.include?(m.to_s)
62
63
  end
63
64
 
64
65
  @thread = Thread.new do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async_methods
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Durand
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-22 00:00:00 -05:00
18
+ date: 2010-06-24 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency