From 6434e1a36caf025530363a16f52d77a5780ecc8a Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Wed, 11 Jun 2014 15:34:14 +0300 Subject: Change dynamic discover of file => class name We needed this, because use of 'def inherited' not idempotent, in Oxidized::Script use case we may need to restart Oxidized, even though it's already loaded, and we won't get class names populated via 'def inherited' anymore. There are quite many optiosn to do this a) filename == class name + no discovery/mapping, very clean - user 'source' must give us model name in exactly right capitalization b) add 'self' at end of files, so eval will return class name + deterministic with arbitrary name - DSL cruft, DSL being light is our main value (can we do this via parent class? I couldn't find way) c) load in new module via Module.module_eval X + module will contain only consts we just created - but which one is the one we want? - if we use eval, load errors won't tell line error But at least now we got rid of 'inherited' methods and not adding too much cruft, hope it's better than before. --- lib/oxidized/model/model.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/model.rb b/lib/oxidized/model/model.rb index 6f4f54d..c3d8760 100644 --- a/lib/oxidized/model/model.rb +++ b/lib/oxidized/model/model.rb @@ -9,7 +9,6 @@ module Oxidized klass.instance_variable_set '@procs', Hash.new { |h,k| h[k] = [] } klass.instance_variable_set '@expect', [] klass.const_set :CFG, CFG - Oxidized.mgr.loader = { :class => klass } end def comment _comment='# ' return @comment if @comment -- cgit v1.2.1