Sha256: 1d7bc1672fa1d84685e8985204c10fef35a798b7e20dbeefab59eb86f357a77e
Contents?: true
Size: 571 Bytes
Versions: 2
Compression:
Stored size: 571 Bytes
Contents
module CsvPiper module Processors class CreateActiveModel def initialize(model_class) @model_class = model_class end def process(_source, transformed, errors) model = @model_class.new(transformed) model.save if model.valid? && errors.empty? errors.errors.merge!(model.errors.to_hash) do |_key, old_val, new_val| old_val + new_val end transformed = transformed.merge({ "#{@model_class.name.underscore}_model".to_sym => model }) [transformed, errors] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
csv_piper-1.0.0 | lib/csv_piper/processors/create_active_model.rb |
csv_piper-0.1.9 | lib/csv_piper/processors/create_active_model.rb |