Class: Rseed::HashAdapter
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Attributes inherited from Adapter
#converter, #error, #logger, #options
Instance Method Summary collapse
-
#initialize(data = nil) ⇒ HashAdapter
constructor
A new instance of HashAdapter.
- #preprocess ⇒ Object
- #process(&block) ⇒ Object
Methods inherited from Adapter
#converter_attributes, #mandatory_attributes
Constructor Details
#initialize(data = nil) ⇒ HashAdapter
Returns a new instance of HashAdapter.
4 5 6 |
# File 'lib/rseed/hash_adapter.rb', line 4 def initialize data = nil @data = data end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
3 4 5 |
# File 'lib/rseed/hash_adapter.rb', line 3 def data @data end |
Instance Method Details
#preprocess ⇒ Object
8 9 10 11 12 |
# File 'lib/rseed/hash_adapter.rb', line 8 def preprocess return false unless @data.is_a? Array or @data.is_a?(Hash) @data = [@data] if @data.is_a?(Hash) true end |
#process(&block) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/rseed/hash_adapter.rb', line 14 def process &block = {} [:total_records] = @data.length @data.each_with_index do |d, i| [:record_count] = i + 1 yield d, end end |