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.



132
133
134
# File 'lib/bricolage/datasource.rb', line 132

def context
  @context
end

#loggerObject (readonly)

Returns the value of attribute logger.



133
134
135
# File 'lib/bricolage/datasource.rb', line 133

def logger
  @logger
end

#nameObject (readonly)

Returns the value of attribute name.



131
132
133
# File 'lib/bricolage/datasource.rb', line 131

def name
  @name
end

Class Method Details

.get_class(type) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
# File 'lib/bricolage/datasource.rb', line 112

def DataSource.get_class(type)
  unless CLASSES[type.to_s]
    begin
      require "bricolage/#{type}datasource"
    rescue LoadError
      raise ParameterError, "no such SQL client 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



92
93
94
95
96
97
98
99
100
# File 'lib/bricolage/datasource.rb', line 92

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)


135
136
137
# File 'lib/bricolage/datasource.rb', line 135

def open
  yield nil
end

#open_for_batch(&block) ⇒ Object



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

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

#redshift_loader_source?Boolean

Returns:

  • (Boolean)


143
144
145
# File 'lib/bricolage/psqldatasource.rb', line 143

def redshift_loader_source?
  false
end