lib/wolverine/path_component.rb in wolverine-0.2.7 vs lib/wolverine/path_component.rb in wolverine-0.3.0

- old
+ new

@@ -16,11 +16,10 @@ # @param path [Pathname] full path to the current file or directory # @param redis [Redis] def initialize path, options = {} @path = path @options = options - @cache_to = options[:cache_to] @redis = options[:redis] || Wolverine.redis @config = options[:config] || Wolverine.config end # @param sym [Symbol] the file or directory to look up and execute @@ -52,36 +51,23 @@ def file?(path) File.exists?(path) && !File.directory?(path) end def define_directory_method path, sym - options = @options.merge({:cache_to => nil}) - dir = PathComponent.new(path, options) - cb = proc { dir } - define_metaclass_method(sym, &cb) - cache_metaclass_method(sym, &cb) + dir = PathComponent.new(path, @options) + define_metaclass_method(sym) { dir } end def define_script_method path, sym, *args - redis, options = @redis, @options.merge({:cache_to => nil}) - script = Wolverine::Script.new(path, options) - cb = proc { |*args| script.call(redis, *args) } - define_metaclass_method(sym, &cb) - cache_metaclass_method(sym, &cb) + script = Wolverine::Script.new(path, @options) + define_metaclass_method(sym) { |*args| + script.call(@redis, *args) + } end def define_metaclass_method sym, &block metaclass = class << self; self; end metaclass.send(:define_method, sym, &block) - end - - def cache_metaclass_method sym, &block - unless @cache_to.nil? - metaclass = class << @cache_to; self; end - metaclass.send(:define_method, sym, &block) - cached_methods = @cache_to.send(:cached_methods) - cached_methods[sym] = self - end end end end