Class: Pobo::DTO::ImportResult

Inherits:
Object
  • Object
show all
Defined in:
lib/pobo/dto/import_result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(success:, imported: 0, updated: 0, skipped: 0, errors: [], values_imported: nil, values_updated: nil) ⇒ ImportResult

Returns a new instance of ImportResult.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pobo/dto/import_result.rb', line 9

def initialize(
  success:,
  imported: 0,
  updated: 0,
  skipped: 0,
  errors: [],
  values_imported: nil,
  values_updated: nil
)
  @success = success
  @imported = imported
  @updated = updated
  @skipped = skipped
  @errors = errors
  @values_imported = values_imported
  @values_updated = values_updated
end

Instance Attribute Details

#errors ⇒ Object (readonly)

Returns the value of attribute errors.



6
7
8
# File 'lib/pobo/dto/import_result.rb', line 6

def errors
  @errors
end

#imported ⇒ Object (readonly)

Returns the value of attribute imported.



6
7
8
# File 'lib/pobo/dto/import_result.rb', line 6

def imported
  @imported
end

#skipped ⇒ Object (readonly)

Returns the value of attribute skipped.



6
7
8
# File 'lib/pobo/dto/import_result.rb', line 6

def skipped
  @skipped
end

#success ⇒ Object (readonly)

Returns the value of attribute success.



6
7
8
# File 'lib/pobo/dto/import_result.rb', line 6

def success
  @success
end

#updated ⇒ Object (readonly)

Returns the value of attribute updated.



6
7
8
# File 'lib/pobo/dto/import_result.rb', line 6

def updated
  @updated
end

#values_imported ⇒ Object (readonly)

Returns the value of attribute values_imported.



6
7
8
# File 'lib/pobo/dto/import_result.rb', line 6

def values_imported
  @values_imported
end

#values_updated ⇒ Object (readonly)

Returns the value of attribute values_updated.



6
7
8
# File 'lib/pobo/dto/import_result.rb', line 6

def values_updated
  @values_updated
end

Class Method Details

.from_hash(hash) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/pobo/dto/import_result.rb', line 27

def self.from_hash(hash)
  new(
    success: hash["success"] || hash[:success] || true,
    imported: hash["imported"] || hash[:imported] || 0,
    updated: hash["updated"] || hash[:updated] || 0,
    skipped: hash["skipped"] || hash[:skipped] || 0,
    errors: hash["errors"] || hash[:errors] || [],
    values_imported: hash["values_imported"] || hash[:values_imported],
    values_updated: hash["values_updated"] || hash[:values_updated]
  )
end

Instance Method Details

#errors? ⇒ Boolean Also known as: has_errors?

Returns:

  • (Boolean)


39
40
41
# File 'lib/pobo/dto/import_result.rb', line 39

def errors?
  !@errors.empty?
end