Class: MiniEtl::Generator
- Inherits:
-
Object
- Object
- MiniEtl::Generator
- Includes:
- Status
- Defined in:
- lib/mini_etl/generator.rb
Overview
Generate record information from a source
Constant Summary collapse
- VALID_STATES =
{ initialized: 0, bootstrapped: 1, transformed: 2, failed: 3 }.freeze
Constants included from Status
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#lazy ⇒ Object
Returns the value of attribute lazy.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#type ⇒ Object
writeonly
Sets the attribute type.
Instance Method Summary collapse
- #bootstrap(type, data) ⇒ Object
-
#initialize ⇒ Generator
constructor
TODO: This needs to know the type of the receiver.
- #transform ⇒ Object
Methods included from Status
Constructor Details
#initialize ⇒ Generator
TODO: This needs to know the type of the receiver
20 21 22 23 24 |
# File 'lib/mini_etl/generator.rb', line 20 def initialize @lazy = false @payload = [] initialized! end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
15 16 17 |
# File 'lib/mini_etl/generator.rb', line 15 def data @data end |
#lazy ⇒ Object
Returns the value of attribute lazy.
15 16 17 |
# File 'lib/mini_etl/generator.rb', line 15 def lazy @lazy end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
17 18 19 |
# File 'lib/mini_etl/generator.rb', line 17 def payload @payload end |
#type=(value) ⇒ Object (writeonly)
Sets the attribute type
16 17 18 |
# File 'lib/mini_etl/generator.rb', line 16 def type=(value) @type = value end |
Instance Method Details
#bootstrap(type, data) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/mini_etl/generator.rb', line 26 def bootstrap(type, data) raise ArgumentError if type.nil? || data.nil? @type = type @data = data bootstrapped! end |
#transform ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/mini_etl/generator.rb', line 34 def transform failed! && return unless bootstrapped? strategy = MiniEtl::Strategy.for(@type) @payload = strategy.generate(@data) transformed! end |