Class: Retl::Transformation
- Inherits:
-
Object
- Object
- Retl::Transformation
- Includes:
- Enumerable
- Defined in:
- lib/retl/transformation.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #each_slice(size, &block) ⇒ Object
- #errors ⇒ Object
- #forks(name) ⇒ Object
-
#initialize(enumerable, path, options = {}) ⇒ Transformation
constructor
A new instance of Transformation.
- #load_into(*destinations) ⇒ Object
Constructor Details
#initialize(enumerable, path, options = {}) ⇒ Transformation
Returns a new instance of Transformation.
9 10 11 12 13 14 15 |
# File 'lib/retl/transformation.rb', line 9 def initialize(enumerable, path, ={}) @enumerable, @path, = enumerable, path, @context = Context.new(@path, ) @fork_data = ForkDataCollector.new(@context) @forks = {} @errors = [] end |
Instance Method Details
#each(&block) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/retl/transformation.rb', line 17 def each(&block) if @each @each.each(&block) else build_each_result(&block) end end |
#each_slice(size, &block) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/retl/transformation.rb', line 25 def each_slice(size, &block) @each_slice ||= {} if @each_slice[size] @each_slice[size].each(&block) else build_each_slice_result(size, &block) end end |
#errors ⇒ Object
57 58 59 |
# File 'lib/retl/transformation.rb', line 57 def errors @errors.each end |
#forks(name) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/retl/transformation.rb', line 34 def forks(name) unless @forks[name] build_each_result @forks[name] = @path.forks(name).transform(@fork_data.take(name), ) end @forks[name] end |
#load_into(*destinations) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/retl/transformation.rb', line 43 def load_into(*destinations) destinations = Array(destinations) each do |data| destinations.each do |destination| destination << data end end destinations.each do |destination| destination.close if destination.respond_to?(:close) end end |