Class: Bricolage::DataSource

Inherits:
Object
  • Object
show all
Defined in:
lib/bricolage/psqldatasource.rb,
lib/bricolage/datasource.rb

Overview

reopen

Constant Summary collapse

CLASSES =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



139
140
141
# File 'lib/bricolage/datasource.rb', line 139

def context
  @context
end

#loggerObject (readonly)

Returns the value of attribute logger.



140
141
142
# File 'lib/bricolage/datasource.rb', line 140

def logger
  @logger
end

#nameObject (readonly)

Returns the value of attribute name.



138
139
140
# File 'lib/bricolage/datasource.rb', line 138

def name
  @name
end

Class Method Details

.get_class(type) ⇒ Object



119
120
121
122
123
124
125
126
127
128
129
# File 'lib/bricolage/datasource.rb', line 119

def DataSource.get_class(type)
  unless CLASSES[type.to_s]
    begin
      require "bricolage/#{type}datasource"
    rescue LoadError
      raise ParameterError, "no such data source type: #{type}"
    end
    raise FatalError, "DataSource class does not exist: #{type}" unless CLASSES[type.to_s]
  end
  CLASSES[type.to_s]
end

.new_for_type(type, name, config, context, logger) ⇒ Object



99
100
101
102
103
104
105
106
107
# File 'lib/bricolage/datasource.rb', line 99

def DataSource.new_for_type(type, name, config, context, logger)
  ds = get_class(type).new(**config)
  ds.__send__ :initialize_base, name, context, logger
  ds
rescue ArgumentError => err
  # FIXME: do not rely on error message
  ent = err.message.slice(/unknown keyword: (\S+)/, 1) or raise
  raise ParameterError, "unknown config entry in database.yml: #{name}.#{ent}"
end

Instance Method Details

#open {|nil| ... } ⇒ Object

Yields:

  • (nil)


142
143
144
# File 'lib/bricolage/datasource.rb', line 142

def open
  yield nil
end

#open_for_batch(&block) ⇒ Object



146
147
148
# File 'lib/bricolage/datasource.rb', line 146

def open_for_batch(&block)
  open(&block)
end

#redshift_loader_source?Boolean

Returns:

  • (Boolean)


151
152
153
# File 'lib/bricolage/psqldatasource.rb', line 151

def redshift_loader_source?
  false
end