Class: Remi::DataTarget
- Inherits:
-
DataSubject
- Object
- DataSubject
- Remi::DataTarget
- Defined in:
- lib/remi/data_subject.rb
Overview
The DataTarget is a DataSubject meant to load data from an associated dataframe into one or more target systems.
Instance Attribute Summary
Attributes inherited from DataSubject
Instance Method Summary collapse
- #df=(new_dataframe) ⇒ Object
-
#encoder(obj = nil) ⇒ Object
The encoder set for this data source.
-
#initialize(*args, **kargs, &block) ⇒ DataTarget
constructor
A new instance of DataTarget.
-
#load ⇒ true
Loads data to all targets.
-
#load! ⇒ nil
Performs the load operation, regardless of whether it has already executed.
-
#loader(obj) ⇒ Array
The full list of loaders.
-
#loaders ⇒ Array
The list of loaders associated with the this data target.
Methods inherited from DataSubject
#df, #df_type, #dsl_eval, #dsl_eval!, #enforce_types, #field_symbolizer, #fields, #fields=
Constructor Details
#initialize(*args, **kargs, &block) ⇒ DataTarget
Returns a new instance of DataTarget.
245 246 247 248 249 |
# File 'lib/remi/data_subject.rb', line 245 def initialize(*args, **kargs, &block) @encoder = Encoder::None.new @encoder.context = self super end |
Instance Method Details
#df=(new_dataframe) ⇒ Object
294 295 296 297 298 |
# File 'lib/remi/data_subject.rb', line 294 def df=(new_dataframe) super loaders.each { |l| l.load encoded_dataframe if l.autoload } df end |
#encoder(obj = nil) ⇒ Object
Returns the encoder set for this data source.
253 254 255 256 257 258 |
# File 'lib/remi/data_subject.rb', line 253 def encoder(obj = nil) return @encoder unless obj obj.context = self @encoder = obj end |
#load ⇒ true
Loads data to all targets. This is automatically called after all transforms have executed, but could also get called manually. The actual load operation is only executed if hasn't already.
277 278 279 280 281 282 283 |
# File 'lib/remi/data_subject.rb', line 277 def load return nil if @loaded || df.size == 0 dsl_eval load! @loaded = true end |
#load! ⇒ nil
Performs the load operation, regardless of whether it has already executed.
289 290 291 292 |
# File 'lib/remi/data_subject.rb', line 289 def load! loaders.each { |l| l.load encoded_dataframe } true end |
#loader(obj) ⇒ Array
Returns the full list of loaders.
267 268 269 270 |
# File 'lib/remi/data_subject.rb', line 267 def loader(obj) obj.context = self loaders << obj unless loaders.include? obj end |
#loaders ⇒ Array
Returns the list of loaders associated with the this data target.
261 262 263 |
# File 'lib/remi/data_subject.rb', line 261 def loaders @loaders ||= [] end |