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 ...@@ -9,6 +9,9 @@ class Application < Ohm::Model
index :name index :name
after :create, :notify_via_redis
after :update, :notify_via_redis
def validate def validate
assert_present :name assert_present :name
assert_unique :name assert_unique :name
...@@ -37,6 +40,12 @@ class Application < Ohm::Model ...@@ -37,6 +40,12 @@ class Application < Ohm::Model
end end
end 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 end
class Applications class Applications
......
...@@ -14,6 +14,9 @@ class Configuration < Ohm::Model ...@@ -14,6 +14,9 @@ class Configuration < Ohm::Model
index :format index :format
index :body index :body
after :create, :notify_via_redis
after :update, :notify_via_redis
def validate def validate
assert_present :name assert_present :name
assert_present :format assert_present :format
...@@ -42,6 +45,12 @@ class Configuration < Ohm::Model ...@@ -42,6 +45,12 @@ class Configuration < Ohm::Model
end end
end 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 end
class Configurations class Configurations
......
...@@ -11,6 +11,9 @@ class Host < Ohm::Model ...@@ -11,6 +11,9 @@ class Host < Ohm::Model
index :name index :name
index :status index :status
after :create, :notify_via_redis
after :update, :notify_via_redis
def validate def validate
assert_present :name assert_present :name
assert_present :status assert_present :status
...@@ -45,6 +48,12 @@ class Host < Ohm::Model ...@@ -45,6 +48,12 @@ class Host < Ohm::Model
end end
end 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 end
class Hosts class Hosts
......
...@@ -11,6 +11,9 @@ class Service < Ohm::Model ...@@ -11,6 +11,9 @@ class Service < Ohm::Model
index :name index :name
index :status index :status
after :create, :notify_via_redis
after :update, :notify_via_redis
def validate def validate
assert_present :name assert_present :name
assert_present :status assert_present :status
...@@ -48,6 +51,12 @@ class Service < Ohm::Model ...@@ -48,6 +51,12 @@ class Service < Ohm::Model
end end
end 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 end
class Services 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