Class: ArtVandelay::Import
- Inherits:
-
Object
- Object
- ArtVandelay::Import
- Defined in:
- lib/art_vandelay.rb
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
- #csv(csv_string, **options) ⇒ Object
-
#initialize(model_name, **options) ⇒ Import
constructor
A new instance of Import.
Constructor Details
#initialize(model_name, **options) ⇒ Import
Returns a new instance of Import.
142 143 144 145 146 147 |
# File 'lib/art_vandelay.rb', line 142 def initialize(model_name, **) @options = .symbolize_keys @rollback = [:rollback] @strip = [:strip] @model_name = model_name end |
Instance Method Details
#csv(csv_string, **options) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/art_vandelay.rb', line 149 def csv(csv_string, **) = .symbolize_keys headers = [:headers] || true attributes = [:attributes] || {} rows = build_csv(csv_string, headers) if rollback # TODO: It would be nice to still return a result object during a # failure active_record.transaction do parse_rows(rows, attributes, raise_on_error: true) end else parse_rows(rows, attributes) end end |