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