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

finally fleshing out links

parent f3813529
module Noah
PROTECTED_PATHS = %w[applications configurations hosts services watches ark noah]
PATH_MAPPING = {"Noah::Application" => "//noah/application",
"Noah::Service" => "//noah/service",
"Noah::Configuration" => "//noah/configuration",
"Noah::Host" => "//noah/host",
"Noah::Tag" => "//noah/tag",
"Noah::Ephemeral" => "//noah/ephemeral"}
PATH_MAPPING = {"applications" => "Application",
"services" => "Service",
"configurations" => "Configuration",
"hosts" => "Host",
"tags" => "Tag",
"ephemeral" => "Ephemeral"}
end
begin
require 'yajl'
......
require File.join(File.dirname(__FILE__), 'link_member')
module Noah
class Link < Model
attribute :path
attribute :source
list :nodes, LinkMember
index :path
index :source
def validate
super
assert_present :path
assert_present :source
assert_unique [:path, :source]
end
# Nothing to see yet.
# This will be for creating "overlays" or "link" relationships
......
module Noah
class LinkMember
class <<self
def create(path)
path_to_instance(path)
end
protected
def path_to_instance(path)
p = path.split('/')
model, name = p[1], p[2]
x = instance_eval(Noah::PATH_MAPPING[model])
x.find(:name => name).first
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