Class: SmartCsvImport::Result
- Inherits:
-
Object
- Object
- SmartCsvImport::Result
- Defined in:
- lib/smart_csv_import/result.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#failed ⇒ Object
readonly
Returns the value of attribute failed.
-
#header_mappings ⇒ Object
readonly
Returns the value of attribute header_mappings.
-
#import_id ⇒ Object
readonly
Returns the value of attribute import_id.
-
#imported ⇒ Object
readonly
Returns the value of attribute imported.
-
#parse_errors ⇒ Object
readonly
Returns the value of attribute parse_errors.
-
#proposed_mappings ⇒ Object
readonly
Returns the value of attribute proposed_mappings.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#unmatched_columns ⇒ Object
readonly
Returns the value of attribute unmatched_columns.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Class Method Summary collapse
- .completed(imported:, failed:, total:, errors:, header_mappings:, import_id: nil, warnings: [], parse_errors: []) ⇒ Object
- .dry_run(imported:, failed:, total:, errors:, header_mappings:, warnings: [], parse_errors: []) ⇒ Object
- .partial_failure(imported:, failed:, total:, errors:, header_mappings:, import_id: nil, warnings: [], parse_errors: []) ⇒ Object
- .queued(import_id:, **rest) ⇒ Object
- .review_required(header_mappings:, import_id: nil, proposed_mappings: {}, unmatched_columns: [], warnings: []) ⇒ Object
Instance Method Summary collapse
- #completed? ⇒ Boolean
- #dry_run? ⇒ Boolean
- #partial_failure? ⇒ Boolean
- #queued? ⇒ Boolean
- #review_required? ⇒ Boolean
- #success? ⇒ Boolean
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
10 11 12 |
# File 'lib/smart_csv_import/result.rb', line 10 def errors @errors end |
#failed ⇒ Object (readonly)
Returns the value of attribute failed.
10 11 12 |
# File 'lib/smart_csv_import/result.rb', line 10 def failed @failed end |
#header_mappings ⇒ Object (readonly)
Returns the value of attribute header_mappings.
10 11 12 |
# File 'lib/smart_csv_import/result.rb', line 10 def header_mappings @header_mappings end |
#import_id ⇒ Object (readonly)
Returns the value of attribute import_id.
10 11 12 |
# File 'lib/smart_csv_import/result.rb', line 10 def import_id @import_id end |
#imported ⇒ Object (readonly)
Returns the value of attribute imported.
10 11 12 |
# File 'lib/smart_csv_import/result.rb', line 10 def imported @imported end |
#parse_errors ⇒ Object (readonly)
Returns the value of attribute parse_errors.
10 11 12 |
# File 'lib/smart_csv_import/result.rb', line 10 def parse_errors @parse_errors end |
#proposed_mappings ⇒ Object (readonly)
Returns the value of attribute proposed_mappings.
10 11 12 |
# File 'lib/smart_csv_import/result.rb', line 10 def proposed_mappings @proposed_mappings end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/smart_csv_import/result.rb', line 10 def status @status end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
10 11 12 |
# File 'lib/smart_csv_import/result.rb', line 10 def total @total end |
#unmatched_columns ⇒ Object (readonly)
Returns the value of attribute unmatched_columns.
10 11 12 |
# File 'lib/smart_csv_import/result.rb', line 10 def unmatched_columns @unmatched_columns end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
10 11 12 |
# File 'lib/smart_csv_import/result.rb', line 10 def warnings @warnings end |
Class Method Details
.completed(imported:, failed:, total:, errors:, header_mappings:, import_id: nil, warnings: [], parse_errors: []) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/smart_csv_import/result.rb', line 16 def self.completed(imported:, failed:, total:, errors:, header_mappings:, import_id: nil, warnings: [], parse_errors: []) new( status: :completed, imported: imported, failed: failed, total: total, errors: errors, header_mappings: header_mappings, import_id: import_id, warnings: warnings, parse_errors: parse_errors ) end |
.dry_run(imported:, failed:, total:, errors:, header_mappings:, warnings: [], parse_errors: []) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/smart_csv_import/result.rb', line 65 def self.dry_run(imported:, failed:, total:, errors:, header_mappings:, warnings: [], parse_errors: []) new( status: :dry_run, imported: imported, failed: failed, total: total, errors: errors, header_mappings: header_mappings, warnings: warnings, parse_errors: parse_errors ) end |
.partial_failure(imported:, failed:, total:, errors:, header_mappings:, import_id: nil, warnings: [], parse_errors: []) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/smart_csv_import/result.rb', line 30 def self.partial_failure(imported:, failed:, total:, errors:, header_mappings:, import_id: nil, warnings: [], parse_errors: []) new( status: :partial_failure, imported: imported, failed: failed, total: total, errors: errors, header_mappings: header_mappings, import_id: import_id, warnings: warnings, parse_errors: parse_errors ) end |
.queued(import_id:, **rest) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/smart_csv_import/result.rb', line 55 def self.queued(import_id:, **rest) invalid_keys = rest.keys & %i[imported failed total] raise ArgumentError, "queued result does not accept: #{invalid_keys.join(", ")}" if invalid_keys.any? new( status: :queued, import_id: import_id ) end |
.review_required(header_mappings:, import_id: nil, proposed_mappings: {}, unmatched_columns: [], warnings: []) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/smart_csv_import/result.rb', line 44 def self.review_required(header_mappings:, import_id: nil, proposed_mappings: {}, unmatched_columns: [], warnings: []) new( status: :review_required, header_mappings: header_mappings, import_id: import_id, proposed_mappings: proposed_mappings, unmatched_columns: unmatched_columns, warnings: warnings ) end |
Instance Method Details
#completed? ⇒ Boolean
78 |
# File 'lib/smart_csv_import/result.rb', line 78 def completed? = status == :completed |
#dry_run? ⇒ Boolean
82 |
# File 'lib/smart_csv_import/result.rb', line 82 def dry_run? = status == :dry_run |
#partial_failure? ⇒ Boolean
79 |
# File 'lib/smart_csv_import/result.rb', line 79 def partial_failure? = status == :partial_failure |
#queued? ⇒ Boolean
81 |
# File 'lib/smart_csv_import/result.rb', line 81 def queued? = status == :queued |
#review_required? ⇒ Boolean
80 |
# File 'lib/smart_csv_import/result.rb', line 80 def review_required? = status == :review_required |
#success? ⇒ Boolean
83 |
# File 'lib/smart_csv_import/result.rb', line 83 def success? = completed? && errors.empty? |