Commit f760cbd7 authored by John E. Vincent's avatar John E. Vincent

Adding a catchall callback for each object type

parent 02fd3c92
......@@ -9,6 +9,9 @@ class Application < Ohm::Model
index :name
after :create, :notify_via_redis
after :update, :notify_via_redis
def validate
assert_present :name
assert_unique :name
......@@ -37,6 +40,12 @@ class Application < Ohm::Model
end
end
end
protected
def notify_via_redis
msg = self.to_hash.merge({:class => self.class})
Ohm.redis.publish(:noah, msg.to_json)
end
end
class Applications
......
......@@ -14,6 +14,9 @@ class Configuration < Ohm::Model
index :format
index :body
after :create, :notify_via_redis
after :update, :notify_via_redis
def validate
assert_present :name
assert_present :format
......@@ -42,6 +45,12 @@ class Configuration < Ohm::Model
end
end
end
protected
def notify_via_redis
msg = self.to_hash.merge({:class => self.class})
Ohm.redis.publish(:noah, msg.to_json)
end
end
class Configurations
......
......@@ -11,6 +11,9 @@ class Host < Ohm::Model
index :name
index :status
after :create, :notify_via_redis
after :update, :notify_via_redis
def validate
assert_present :name
assert_present :status
......@@ -45,6 +48,12 @@ class Host < Ohm::Model
end
end
end
protected
def notify_via_redis
msg = self.to_hash.merge({:class => self.class})
Ohm.redis.publish(:noah, msg.to_json)
end
end
class Hosts
......
......@@ -11,6 +11,9 @@ class Service < Ohm::Model
index :name
index :status
after :create, :notify_via_redis
after :update, :notify_via_redis
def validate
assert_present :name
assert_present :status
......@@ -48,6 +51,12 @@ class Service < Ohm::Model
end
end
end
protected
def notify_via_redis
msg = self.to_hash.merge({:class => self.class})
Ohm.redis.publish(:noah, msg.to_json)
end
end
class Services
......
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