Class: Importu::Sources::Ruby
- Inherits:
-
Object
- Object
- Importu::Sources::Ruby
- Defined in:
- lib/importu/sources/ruby.rb
Overview
Uses Ruby objects as import source data.
Accepts an array of hashes or any enumerable that yields objects responding to #to_hash. Hash keys should be strings to match other source formats.
Instance Method Summary collapse
-
#close ⇒ void
No-op for Ruby source (no file handles to close).
-
#initialize(data) ⇒ Ruby
constructor
Creates a new Ruby source.
-
#rows ⇒ Enumerator<Hash>
Returns an enumerator that yields each element as a hash.
-
#write_errors(summary, only_errors: false) ⇒ nil
Not implemented for Ruby source.
Constructor Details
#initialize(data) ⇒ Ruby
Creates a new Ruby source.
19 20 21 |
# File 'lib/importu/sources/ruby.rb', line 19 def initialize(data, **) @data = data end |
Instance Method Details
#close ⇒ void
This method returns an undefined value.
No-op for Ruby source (no file handles to close).
Provided for API consistency with file-based sources.
44 |
# File 'lib/importu/sources/ruby.rb', line 44 def close; end |
#rows ⇒ Enumerator<Hash>
Returns an enumerator that yields each element as a hash.
26 27 28 29 30 |
# File 'lib/importu/sources/ruby.rb', line 26 def rows Enumerator.new do |yielder| @data.each {|row| yielder.yield(row.to_hash) } end end |
#write_errors(summary, only_errors: false) ⇒ nil
Not implemented for Ruby source.
37 |
# File 'lib/importu/sources/ruby.rb', line 37 def write_errors(summary, only_errors: false); end |