class CSVStepImporter::Row
Attributes
attributes[RW]
cache[RW]
row_number[RW]
Public Class Methods
new(parent:, row_number:, **attributes)
click to toggle source
Logic
Calls superclass method
CSVStepImporter::Node::new
# File lib/csv_step_importer/row.rb, line 17 def initialize(parent:, row_number:, **attributes) super parent: parent self.cache = {} self.attributes = attributes self.row_number = row_number end
Public Instance Methods
create_or_update()
click to toggle source
# File lib/csv_step_importer/row.rb, line 25 def create_or_update # Rowの保存処理は基本的にstepsで行います true end
dao_for(model, pluralize: false)
click to toggle source
retrieve a dao for a different model using the same CSV row. This is useful e.g. if you use the reflector to get ids of related data
# File lib/csv_step_importer/row.rb, line 31 def dao_for(model, pluralize: false) cache[model.cache_key(pluralize: pluralize)] end
headers()
click to toggle source
# File lib/csv_step_importer/row.rb, line 39 def headers ancestors.find { |ancestor|ancestor.respond_to?(:headers) }&.headers end
include_row?()
click to toggle source
# File lib/csv_step_importer/row.rb, line 35 def include_row? ignore_invalid_rows ? valid? : true end
method_missing(sym, *)
click to toggle source
Calls superclass method
# File lib/csv_step_importer/row.rb, line 43 def method_missing(sym, *) attributes.fetch(sym) { attributes.fetch(sym.to_s) { headers&.include?(sym) ? nil : super } } end