Class: CanadianTire::StoreAddressesImporter::Result

Inherits:
Data
  • Object
show all
Defined in:
app/services/canadian_tire/store_addresses_importer.rb

Overview

Outcome of a full-refresh run.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(before_count: 0, after_count: 0, inserted: 0, errors: []) ⇒ Result

Returns a new instance of Result.



67
# File 'app/services/canadian_tire/store_addresses_importer.rb', line 67

def initialize(before_count: 0, after_count: 0, inserted: 0, errors: []) = super

Instance Attribute Details

#after_countObject (readonly)

Returns the value of attribute after_count

Returns:

  • (Object)

    the current value of after_count



66
67
68
# File 'app/services/canadian_tire/store_addresses_importer.rb', line 66

def after_count
  @after_count
end

#after_count [Integer] rows in the table after the run([Integer]) ⇒ Object (readonly)

(equal to +before_count+ on +dry_run+).



66
67
68
69
70
71
72
# File 'app/services/canadian_tire/store_addresses_importer.rb', line 66

Result = Data.define(:before_count, :after_count, :inserted, :errors) do
  def initialize(before_count: 0, after_count: 0, inserted: 0, errors: []) = super
  def success? = errors.empty?
  def summary
    "before=#{before_count} after=#{after_count} inserted=#{inserted} errors=#{errors.length}"
  end
end

#before_countObject (readonly)

Returns the value of attribute before_count

Returns:

  • (Object)

    the current value of before_count



66
67
68
# File 'app/services/canadian_tire/store_addresses_importer.rb', line 66

def before_count
  @before_count
end

#before_count [Integer] rows in the table before the run.([Integer]) ⇒ Object (readonly)

Outcome of a full-refresh run.



66
67
68
69
70
71
72
# File 'app/services/canadian_tire/store_addresses_importer.rb', line 66

Result = Data.define(:before_count, :after_count, :inserted, :errors) do
  def initialize(before_count: 0, after_count: 0, inserted: 0, errors: []) = super
  def success? = errors.empty?
  def summary
    "before=#{before_count} after=#{after_count} inserted=#{inserted} errors=#{errors.length}"
  end
end

#errorsObject (readonly)

Returns the value of attribute errors

Returns:

  • (Object)

    the current value of errors



66
67
68
# File 'app/services/canadian_tire/store_addresses_importer.rb', line 66

def errors
  @errors
end

#errors [Array<Hash>] read-time failures —([Array<Hash>]) ⇒ Object (readonly)

missing headers, etc. Per-row insert failures abort the whole
transaction (we want all-or-nothing for a full refresh).



66
67
68
69
70
71
72
# File 'app/services/canadian_tire/store_addresses_importer.rb', line 66

Result = Data.define(:before_count, :after_count, :inserted, :errors) do
  def initialize(before_count: 0, after_count: 0, inserted: 0, errors: []) = super
  def success? = errors.empty?
  def summary
    "before=#{before_count} after=#{after_count} inserted=#{inserted} errors=#{errors.length}"
  end
end

#insertedObject (readonly)

Returns the value of attribute inserted

Returns:

  • (Object)

    the current value of inserted



66
67
68
# File 'app/services/canadian_tire/store_addresses_importer.rb', line 66

def inserted
  @inserted
end

#inserted [Integer] rows the sheet contained and([Integer]) ⇒ Object (readonly)

that would have been inserted (equal to +after_count+ on a live run).



66
67
68
69
70
71
72
# File 'app/services/canadian_tire/store_addresses_importer.rb', line 66

Result = Data.define(:before_count, :after_count, :inserted, :errors) do
  def initialize(before_count: 0, after_count: 0, inserted: 0, errors: []) = super
  def success? = errors.empty?
  def summary
    "before=#{before_count} after=#{after_count} inserted=#{inserted} errors=#{errors.length}"
  end
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


68
# File 'app/services/canadian_tire/store_addresses_importer.rb', line 68

def success? = errors.empty?

#summaryObject



69
70
71
# File 'app/services/canadian_tire/store_addresses_importer.rb', line 69

def summary
  "before=#{before_count} after=#{after_count} inserted=#{inserted} errors=#{errors.length}"
end