Permalink
Browse files

Merge branch 'master' of git://github.com/ezmobius/nanite

* 'master' of git://github.com/ezmobius/nanite:
  test added to dispatcher_spec for default actor action
  added default index option for actors
  Need yaml
  Added support for yaml marshalling, and the ability for optional marshallers to be added and used reliably. Optional support for cascading deserialization by un-setting the format option (set to nil)
  • Loading branch information...
2 parents be32bb0 + 2f4dcc6 commit b0afbf5124dfb174a6ee730de99502ea131b86d3 @raggi committed Jan 28, 2009
Showing with 16 additions and 3 deletions.
  1. +2 −0 lib/nanite/agent.rb
  2. +1 −1 lib/nanite/dispatcher.rb
  3. +13 −2 spec/dispatcher_spec.rb
View
@@ -1,3 +1,5 @@
+require 'yaml'
+
module Nanite
class Agent
attr_reader :identity, :format, :status_proc, :results, :root, :log_dir, :vhost, :file_root, :files, :host
@@ -46,7 +46,7 @@ def dispatch_request(req)
_, prefix, meth = req.type.split('/')
begin
actor = @actors[prefix]
- res = actor.send(meth, req.payload)
+ res = actor.send((meth.nil? ? "index" : meth), req.payload)
rescue Exception => e
res = "#{e.class.name}: #{e.message}\n #{e.backtrace.join("\n ")}"
end
@@ -6,7 +6,11 @@
class Foo < Nanite::Actor
- expose :bar
+ expose :bar, :index
+
+ def index(payload)
+ bar(payload)
+ end
def bar(payload)
['hello', payload]
@@ -36,9 +40,16 @@ def bar(payload)
res.token.should == req.token
end
+ it "should dispatch a request for default action" do
+ req = Nanite::Request.new('/foo', 'payload', 'from', '0xdeadbeef', 'reply_to')
+ res = @dispatcher.dispatch_request(req)
+ res.should be_kind_of Nanite::Result
+ res.token.should == req.token
+ end
+
it "should know about all services" do
@dispatcher.register(Foo.new)
- @dispatcher.all_services.should == ['/foo/bar']
+ @dispatcher.all_services.should == ['/foo/bar', '/foo/index']
end
end

0 comments on commit b0afbf5

Please sign in to comment.