Method: Bulk::Collection#to_hash
- Defined in:
- lib/bulk/collection.rb
#to_hash(name, options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/bulk/collection.rb', line 32 def to_hash(name, = {}) only_ids = [:only_ids] response = {} each do |id, record| next if errors.get(id) response[name] ||= [] response[name] << (only_ids ? record.id : record.as_json([:as_json_options]) ) end errors.each do |id, error| response[:errors] ||= {name => {}} response[:errors][name][id] = error.to_hash end response end |