Class: FileStore::BaseFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/filestore/factory.rb

Overview

Base factory class

Class Method Summary collapse

Class Method Details

.create(klass, path, observable = false, logger = StdoutLogger) ⇒ Object

Creates a new instance of the given class

Arguments:

klass: The class to be instantiated
path: The path to be used wether for stores or managers
observable (optional): Determines wether this instance should support observation
logger (optional): The logging facility

Returns:

A new instance of 'klass'


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/filestore/factory.rb', line 24

def self.create(klass, path, observable = false, logger = StdoutLogger)
  logger.debug "Creating new instance of class #{klass} with path '#{path}'"
  obj = klass.new path
  
  obj.logger = logger if not logger.nil?
  
  if observable then
    logger.debug "Extending instance with module 'ObservedSubject'"
    
    obj.extend ObservedSubject
    obj.initialize_obs 
  end
  
  return obj
end