Class: LogCabin::Collection
- Inherits:
-
Object
- Object
- LogCabin::Collection
- Defined in:
- lib/logcabin/collection.rb
Overview
Define a collection of modules
Instance Attribute Summary collapse
-
#load_path ⇒ Object
readonly
Returns the value of attribute load_path.
Instance Method Summary collapse
-
#find(name) ⇒ Object
Method for finding modules to load.
-
#initialize(params = {}) ⇒ Collection
constructor
A new instance of Collection.
Constructor Details
#initialize(params = {}) ⇒ Collection
7 8 9 10 11 |
# File 'lib/logcabin/collection.rb', line 7 def initialize(params = {}) @load_path = params[:load_path] || fail('Load path must be provided') @load_path = [@load_path] if @load_path.is_a? String @modules = {} end |
Instance Attribute Details
#load_path ⇒ Object (readonly)
Returns the value of attribute load_path.
5 6 7 |
# File 'lib/logcabin/collection.rb', line 5 def load_path @load_path end |
Instance Method Details
#find(name) ⇒ Object
Method for finding modules to load
15 16 17 18 19 20 21 |
# File 'lib/logcabin/collection.rb', line 15 def find(name) return @modules[name] if @modules[name] file = find_file(name) require file class_name = parse_class_name(name) @modules[name] = LogCabin::Modules.const_get(class_name) end |