Commit 360dea62 authored by John E. Vincent's avatar John E. Vincent

forgot to run specs before last commit. should have =/

parent bdee7f75
...@@ -36,20 +36,18 @@ module Noah ...@@ -36,20 +36,18 @@ module Noah
end end
def dbnum def dbnum
require 'uri'
o = Ohm.options.first o = Ohm.options.first
if o[:db].nil? && o[:url].nil? return "0" if o.nil?
# We're on db 0 return "0" if (o[:db].nil? && o[:url].nil?)
"0" o[:db].nil? ? "#{o[:url].split('/').last}" : "#{o[:db]}"
else
o[:db].nil? ? "#{o[:url].split('/').last}" : "#{o[:db]}"
end
end end
["save", "create", "update", "delete"].each do |meth| ["save", "create", "update", "delete"].each do |meth|
class_eval do class_eval do
define_method("notify_via_redis_#{meth}".to_sym) do define_method("notify_via_redis_#{meth}".to_sym) do
db = self.dbnum
self.name.nil? ? name=@deleted_name : name=self.name self.name.nil? ? name=@deleted_name : name=self.name
pub_category = "#{dbnum}:noah.#{self.class.to_s}[name].#{meth}" pub_category = "#{db}:noah.#{self.class.to_s}[name].#{meth}"
Ohm.redis.publish(pub_category, self.to_json) Ohm.redis.publish(pub_category, self.to_json)
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment