A thin wrapper around the event_bus
gem to provide a simple interface
for Thincloud applications. Still a work in progress.
require 'thincloud/messagebus'
# Mix it into your application wherever you want
module MyApplication
extend Thincloud::Messagebus
end
# Now you have `publish` and `subscribe` methods
MyApplication.publish()
MyApplication.subscribe()
Mix it in to your application as above and optionally bring along ActiveRecord goodness.
require "thincloud/messagebus/active_record"
class Foo < ActiveRecord::Base
include Thincloud::Messagebus::ActiveRecord
end
#### Now you can subscribe to the model
MyApplication.subscribe_to_model()
# Load all subscribers since the subscriber directory is not auto-loaded.
#
# We don't want to auto-load the directory because we don't have
# class/module/filename parity in there.
Dir["#{Rails.root}/app/subscribers/*.rb"].each do |file|
require_dependency file
end
event_bus
gem
$ gem install thincloud-messagebus
Copyright (c) 2014 New Leaders
See LICENSE.txt for details.