Class: Bricolage::DataSourceFactory
- Inherits:
-
Object
- Object
- Bricolage::DataSourceFactory
- Defined in:
- lib/bricolage/datasource.rb
Defined Under Namespace
Classes: Loader
Constant Summary collapse
- DEFAULT_CONFIG_FILE_NAME =
'database.yml'
- DEFAULT_PASSWORD_FILE_NAME =
'password.yml'
- BUILTIN_TYPES =
%w(generic file ruby)
Class Method Summary collapse
Instance Method Summary collapse
-
#[](name) ⇒ Object
Ruby API.
-
#get(kind, name) ⇒ Object
For job classes.
-
#initialize(configs, context, logger) ⇒ DataSourceFactory
constructor
A new instance of DataSourceFactory.
Constructor Details
#initialize(configs, context, logger) ⇒ DataSourceFactory
Returns a new instance of DataSourceFactory.
46 47 48 49 50 |
# File 'lib/bricolage/datasource.rb', line 46 def initialize(configs, context, logger) @configs = configs @context = context @logger = logger end |
Class Method Details
.load(context, logger) ⇒ Object
8 9 10 11 12 |
# File 'lib/bricolage/datasource.rb', line 8 def DataSourceFactory.load(context, logger) loader = Loader.new(context, logger) loader.load_passwords loader.load end |
Instance Method Details
#[](name) ⇒ Object
Ruby API
66 67 68 69 70 71 72 73 |
# File 'lib/bricolage/datasource.rb', line 66 def [](name) if BUILTIN_TYPES.include?(name) return DataSource.new_for_type(name, name, {}, @context, @logger) end conf = config(name) type = conf.delete(:type) DataSource.new_for_type(type, name, conf, @context, @logger) end |
#get(kind, name) ⇒ Object
For job classes
55 56 57 58 59 60 61 62 63 |
# File 'lib/bricolage/datasource.rb', line 55 def get(kind, name) if BUILTIN_TYPES.include?(kind) return DataSource.new_for_type(kind, kind, {}, @context, @logger) end entry_name = name || kind conf = config(entry_name) type = conf.delete(:type) DataSource.new_for_type(type, entry_name, conf, @context, @logger) end |