class DbSucker::Application::Container::Variation

Constants

ImporterNotFoundError
InvalidImporterFlagError

Attributes

cfg[R]
data[R]
name[R]

Public Class Methods

new(cfg, name, data) click to toggle source
# File lib/db_sucker/application/container/variation.rb, line 14
def initialize cfg, name, data
  @cfg, @name, @data = cfg, name, data

  if data["base"]
    bdata = cfg.variation(data["base"]) || raise(ConfigurationError, "variation `#{cfg.name}/#{name}' cannot base from `#{data["base"]}' since it doesn't exist (in `#{cfg.src}')")
    @data = data.reverse_merge(bdata.data)
  end

  if @data["adapter"]
    begin
      adapter = "DbSucker::Adapters::#{@data["adapter"].camelize}::Api".constantize
      @cfg.app.sync { adapter.require_dependencies }
      extend adapter
    rescue NameError => ex
      raise(AdapterNotFoundError, "variation `#{cfg.name}/#{name}' defines invalid adapter `#{@data["adapter"]}' (in `#{cfg.src}'): #{ex.message}", ex.backtrace)
    end
  elsif @data["database"]
    raise(ConfigurationError, "variation `#{cfg.name}/#{name}' must define an adapter (mysql2, postgres, ...) if database is provided (in `#{cfg.src}')")
  end
end

Public Instance Methods

dump_command_for(table) click to toggle source
# File lib/db_sucker/application/container/variation.rb, line 54
def dump_command_for table
  raise NotImplementedError, "your selected adapter `#{@data["adapter"]}' must implement `#dump_command_for(table)' for variation `#{cfg.name}/#{name}' (in `#{cfg.src}')"
end