Permalink
Browse files

Proxy's now inherit from ActiveSupport::BasicObject

  • Loading branch information...
1 parent 4c391a2 commit 27da4568c077e444c07d92903027f9c96a37e4c6 @markbates committed May 11, 2009
View
@@ -24,7 +24,6 @@ require 'spec/rake/spectask'
s.has_rdoc = true
s.rubyforge_project = "distribunaut"
s.add_dependency('configatron')
- s.add_dependency('cachetastic')
s.add_dependency('addressable')
s.add_dependency('daemons')
# s.test_files = FileList['spec/**/*']
@@ -22,25 +22,20 @@ def self.included(base) # :nodoc:
end
c_name = base.name.gsub('::', '_')
eval %{
- class ::Distribunaut::Distributed::#{c_name}Proxy
- include Singleton
- include DRbUndumped
+ class ::Distribunaut::Distributed::#{c_name}Proxy < ActiveSupport::BasicObject
def method_missing(sym, *args)
#{base}.send(sym, *args)
end
-
- def inspect
- #{base}.inspect
- end
-
- def to_s
- #{base}.to_s
- end
end
}
- obj = "Distribunaut::Distributed::#{c_name}Proxy".constantize.instance
+ const = "Distribunaut::Distributed::#{c_name}Proxy".constantize
+ const.class_eval do
+ include Singleton
+ include ::DRbUndumped
+ end
+ obj = const.instance
raise Distribunaut::Distributed::Errors::ApplicationNameUndefined.new if configatron.distribunaut.app_name.nil?
Distribunaut::Utils::Rinda.register_or_renew(:space => "#{base}".to_sym,
:object => obj,
@@ -27,8 +27,6 @@ class Dylan
include Distribunaut::Distributable
end
Distribunaut::Distributed.should be_const_defined('DylanProxy')
- Distribunaut::Distributed::DylanProxy.instance.should be_kind_of(::Singleton)
- Distribunaut::Distributed::DylanProxy.instance.should be_kind_of(::DRbUndumped)
end
it 'should create proxy objects for modularize classes' do
@@ -39,8 +37,33 @@ class Dylan
end
end
Distribunaut::Distributed.should be_const_defined('Bob_DylanProxy')
- Distribunaut::Distributed::Bob_DylanProxy.instance.should be_kind_of(::Singleton)
- Distribunaut::Distributed::Bob_DylanProxy.instance.should be_kind_of(::DRbUndumped)
+ end
+
+ it 'should pass calls from the proxy to the base object' do
+ class Axl
+ include Distribunaut::Distributable
+
+ def inspect
+ "Sweet Child O'Mine"
+ end
+
+ def yell
+ 'YEAH!!!!'
+ end
+
+ def self.find
+ [self.new, self.new]
+ end
+
+ end
+
+ axl_proxy = Distribunaut::Distributed::Axl.new
+ axl_proxy.inspect.should == "Sweet Child O'Mine"
+ axl_proxy.yell.should == 'YEAH!!!!'
+
+ axls = Distribunaut::Distributed::Axl.find
+ axls.should be_kind_of(Array)
+ axls.size.should == 2
end
end
@@ -15,7 +15,7 @@ def processor
"Intel"
end
end
- Distribunaut::Distributed::Computer.should be_kind_of(Distribunaut::Distributed::ComputerProxy)
+ Distribunaut::Distributed::Computer.should be ::Computer
comp = Distribunaut::Distributed::Computer.new
comp.processor.should == "Intel"
end

0 comments on commit 27da456

Please sign in to comment.