Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit b0afbf5124dfb174a6ee730de99502ea131b86d3 2 parents be32bb0 + 2f4dcc6
James Tucker authored
2  lib/nanite/agent.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
2  lib/nanite/dispatcher.rb
View
@@ -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
15 spec/dispatcher_spec.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.