def set(args)
validate(
args,
{
:platform => {
:kind_of => Symbol,
:required => false
},
:version => {
:kind_of => String,
:required => false
},
:short_name => {
:kind_of => Symbol,
:required => true
},
:resource => {
:kind_of => [ String, Symbol, Class ],
:required => true
}
}
)
if args.has_key?(:platform)
if args.has_key?(:version)
if map.has_key?(args[:platform])
if map[args[:platform]].has_key?(args[:version])
map[args[:platform]][args[:version]][args[:short_name].to_sym] = args[:resource]
else
map[args[:platform]][args[:version]] = {
args[:short_name].to_sym => args[:resource]
}
end
else
map[args[:platform]] = {
args[:version] => {
args[:short_name].to_sym => args[:resource]
}
}
end
else
if map.has_key?(args[:platform])
if map[args[:platform]].has_key?(:default)
map[args[:platform]][:default][args[:short_name].to_sym] = args[:resource]
else
map[args[:platform]] = { :default => { args[:short_name].to_sym => args[:resource] } }
end
else
map[args[:platform]] = {
:default => {
args[:short_name].to_sym => args[:resource]
}
}
end
end
else
if map.has_key?(:default)
map[:default][args[:short_name].to_sym] = args[:resource]
else
map[:default] = {
args[:short_name].to_sym => args[:resource]
}
end
end
end