Class: DataMiner::Step::Import
- Inherits:
-
DataMiner::Step
- Object
- DataMiner::Step
- DataMiner::Step::Import
- 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
-
#attributes ⇒ Array<DataMiner::Attribute>
readonly
The mappings of local columns to remote data source fields.
-
#description ⇒ String
readonly
Description of what this step does.
Instance Method Summary collapse
-
#key(attr_name, attr_options = {}) ⇒ nil
Store data into a model column AND use it as the key.
-
#store(attr_name, attr_options = {}) ⇒ nil
Store data into a model column.
Instance Attribute Details
#attributes ⇒ Array<DataMiner::Attribute> (readonly)
The mappings of local columns to remote data source fields.
16 17 18 |
# File 'lib/data_miner/step/import.rb', line 16 def attributes @attributes end |
#description ⇒ String (readonly)
Description of what this step does.
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.
76 77 78 79 80 81 82 83 |
# File 'lib/data_miner/step/import.rb', line 76 def key(attr_name, = {}) 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, end |
#store(attr_name, attr_options = {}) ⇒ nil
Store data into a model column.
57 58 59 60 61 62 63 |
# File 'lib/data_miner/step/import.rb', line 57 def store(attr_name, = {}) 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, end |