Sha256: e631adde42fb40839982c50a6581d030415a7b8c384490bb1c7771f3f0ddfac3
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
## # Support dynamic loading of modules at runtime module LogCabin class << self ## # Insert a helper .new() method for creating a new Cache object def new(*args) self::DirCollection.new(*args) end end ## # Empty module for namespacing dynamic modules module Modules end ## # Basic collection object for subclassing class BaseCollection def initialize(_) @modules = {} end private def cache(name) @modules[name] ||= yield end def load_class_from_module(mod_name, name) require mod_name class_name = parse_class_name(name) LogCabin::Modules.const_get(class_name) rescue LoadError raise("Error while loading #{mod_name} / #{class_name}") end ## # Convert file name to class name # Borrowed with love from Homebrew: http://git.io/vEoDg def parse_class_name(name) class_name = name.to_s.capitalize class_name.gsub(/[-_.\s]([a-zA-Z0-9])/) { Regexp.last_match[1].upcase } end end end require 'logcabin/dircollection' require 'logcabin/gemcollection'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
logcabin-0.1.3 | lib/logcabin.rb |