Class: DataMiner::Step::Import

Inherits:
DataMiner::Step show all
Defined in:
lib/data_miner/step/import.rb

Overview

A step that imports data from a remote source.

Create these by calling import inside a data_miner block.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesArray<DataMiner::Attribute> (readonly)

The mappings of local columns to remote data source fields.

Returns:



16
17
18
# File 'lib/data_miner/step/import.rb', line 16

def attributes
  @attributes
end

#descriptionString (readonly)

Description of what this step does.

Returns:

  • (String)


23
24
25
# File 'lib/data_miner/step/import.rb', line 23

def description
  @description
end

Instance Method Details

#key(attr_name, attr_options = {}) ⇒ nil

Store data into a model column AND use it as the key.

Enables idempotency. In other words, you can run the data miner script multiple times, get updated data, and not get duplicate rows.

Parameters:

  • attr_name (Symbol)

    The name of the local model column.

  • attr_options (optional, Hash) (defaults to: {})

    Options that will be passed to DataMiner::Attribute.new

Options Hash (attr_options):

  • anything (*)

    Any option for DataMiner::Attribute.

Returns:

  • (nil)

See Also:



76
77
78
79
80
81
82
83
# File 'lib/data_miner/step/import.rb', line 76

def key(attr_name, attr_options = {})
  attr_name = attr_name.to_sym
  if attributes.has_key? attr_name
    raise "You should only call store or key once for #{model.name}##{attr_name}"
  end
  @key = attr_name
  store attr_name, attr_options
end

#store(attr_name, attr_options = {}) ⇒ nil

Store data into a model column.

Parameters:

  • attr_name (Symbol)

    The name of the local model column.

  • attr_options (optional, Hash) (defaults to: {})

    Options that will be passed to DataMiner::Attribute.new

Options Hash (attr_options):

  • anything (*)

    Any option for DataMiner::Attribute.

Returns:

  • (nil)

See Also:



57
58
59
60
61
62
63
# File 'lib/data_miner/step/import.rb', line 57

def store(attr_name, attr_options = {})
  attr_name = attr_name.to_sym
  if attributes.has_key? attr_name
    raise "You should only call store or key once for #{model.name}##{attr_name}"
  end
  attributes[attr_name] = DataMiner::Attribute.new self, attr_name, attr_options
end