Core libraries and tools part for pro architecture. It's a submodule - use from this perspective http://git.maniak.pro/madmaniak/pro
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

29 lines
729 B

$services = {}
module Namespacer
def self.make(path, sclass, block, prefix = 'front')
ns = prepare(path, prefix)
modules = ns.split('/').map(&:camelize)
klass = modules.pop
$services[ns] = \
modules.inject(Kernel) { |mod, mod_name|
if mod.const_defined?("#{mod.to_s}::#{mod_name}")
then mod.const_get(mod_name)
else mod.const_set(mod_name, Module.new)
end
}.const_set klass, Class.new(sclass, &block)
end
def self.take(path, prefix = 'front')
prepare(path, prefix).gsub(/\/\w+$/, "" ).camelize.constantize
end
def self.prepare(path, prefix)
"#{prefix}/#{path.gsub!(/^#{ENV['root']}\//, '')}"[0...-3] # [0...-3] rm .rb
end
end
NS = Namespacer