Sha256: fc1f7c0f3c5ae700f8ea46fbc997f0386321ccdefbe16db97f8312966c56cd9f
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 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::Collection.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(name) require name class_name = parse_class_name(name) LogCabin::Modules.const_get(class_name) rescue LoadError raise("Error while loading #{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.0 | lib/logcabin.rb |