Commit 9bcf0599 authored by John E. Vincent's avatar John E. Vincent

moving name back to models in prep for watchers

parent 89005432
...@@ -9,8 +9,6 @@ module Noah ...@@ -9,8 +9,6 @@ module Noah
model.send :include, Ohm::Callbacks model.send :include, Ohm::Callbacks
model.send :include, Ohm::ExtraValidations model.send :include, Ohm::ExtraValidations
model.attribute :name
model.index :name
model.after :save, :notify_via_redis_save model.after :save, :notify_via_redis_save
model.after :create, :notify_via_redis_create model.after :create, :notify_via_redis_create
model.after :update, :notify_via_redis_update model.after :update, :notify_via_redis_update
...@@ -21,10 +19,6 @@ module Noah ...@@ -21,10 +19,6 @@ module Noah
end end
module ModelClassMethods module ModelClassMethods
def validate
super
assert_present :name
end
def is_new? def is_new?
self.created_at == self.updated_at self.created_at == self.updated_at
......
require File.join(File.dirname(__FILE__), 'configurations') require File.join(File.dirname(__FILE__), 'configurations')
module Noah module Noah
class Application < Model class Application < Model
attribute :name
collection :configurations, Configuration collection :configurations, Configuration
index :name
def validate
super
assert_present :name
end
def to_hash def to_hash
arr = [] arr = []
configurations.sort.each {|c| arr << c.to_hash} configurations.sort.each {|c| arr << c.to_hash}
......
module Noah module Noah
class Configuration < Model class Configuration < Model
attribute :name
attribute :format attribute :format
attribute :body attribute :body
attribute :new_record attribute :new_record
reference :application, Application reference :application, Application
index :name
index :format index :format
index :body index :body
def validate def validate
super super
assert_present :name
assert_present :format assert_present :format
assert_present :body assert_present :body
assert_present :application_id assert_present :application_id
......
...@@ -4,13 +4,16 @@ module Noah ...@@ -4,13 +4,16 @@ module Noah
# Host model # Host model
# @return {Host} a {Host} object # @return {Host} a {Host} object
attribute :name
attribute :status attribute :status
collection :services, Service collection :services, Service
index :name
index :status index :status
def validate def validate
super super
assert_present :name
assert_present :status assert_present :status
assert_unique :name assert_unique :name
assert_member :status, ["up","down","pending"] assert_member :status, ["up","down","pending"]
......
...@@ -2,13 +2,16 @@ module Noah ...@@ -2,13 +2,16 @@ module Noah
class Service < Model class Service < Model
attribute :name
attribute :status attribute :status
reference :host, Host reference :host, Host
index :name
index :status index :status
def validate def validate
super super
assert_present :name
assert_present :status assert_present :status
assert_present :host_id assert_present :host_id
assert_unique [:name, :host_id] assert_unique [:name, :host_id]
......
module Noah module Noah
class Watcher < Model #NYI class Watcher < Model #NYI
# This is a "special rainbow" of a class
attribute :client attribute :client
attribute :pattern
attribute :endpoint attribute :endpoint
attribute :event
attribute :action
index :client index :client
index :event index :pattern
index :endpoint
def validate def validate
assert_present :client, :endpoint, :event, :action super
assert_unique [:client, :endpoint, :event, :action] assert_present :client, :endpoint, :pattern
assert_unique [:client, :endpoint, :pattern]
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