Class: Remi::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/remi/loader.rb

Overview

A loader is an object meant to load data into a some external system. This is a parent class meant to be inherited by child classes that define specific ways to load data.

Defined Under Namespace

Classes: DataFrame, LocalFile, None, Postgres, Salesforce, SalesforceSoap, SftpFile, SubJob

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, context: nil, logger: Remi::Settings.logger, **kargs, &block) ⇒ Loader

Returns a new instance of Loader.



7
8
9
10
# File 'lib/remi/loader.rb', line 7

def initialize(*args, context: nil, logger: Remi::Settings.logger, **kargs, &block)
  @context = context
  @logger = logger
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



12
13
14
# File 'lib/remi/loader.rb', line 12

def context
  @context
end

#loggerObject

Returns the value of attribute logger.



12
13
14
# File 'lib/remi/loader.rb', line 12

def logger
  @logger
end

Instance Method Details

#autoloadObject

If autoload is set to true, then any loaders are called at the moment a dataframe is assigned to a target (e.g., my_target.df = some_df will call #load on any loaders associated with my_target).



25
26
27
# File 'lib/remi/loader.rb', line 25

def autoload
  false
end

#fieldsRemi::Fields

Returns The fields defined in the context.

Returns:



30
31
32
# File 'lib/remi/loader.rb', line 30

def fields
  context && context.respond_to?(:fields) ? context.fields : Remi::Fields.new({})
end

#load(data) ⇒ true

Any child classes need to define a load method that loads data from the given dataframe into the target system.

Parameters:

  • data (Remi::DataFrame)

    Data that has been encoded appropriately to be loaded into the target

Returns:

  • (true)

    On success

Raises:

  • (NoMethodError)


18
19
20
# File 'lib/remi/loader.rb', line 18

def load(data)
  raise NoMethodError, "#{__method__} not defined for #{self.class.name}"
end