Class: BatchLoad::RowParse

Inherits:
Object
  • Object
show all
Defined in:
lib/batch_load/row_parse.rb

Overview

The result of parsing a row.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (RowParse) initialize

Returns a new instance of RowParse



13
14
15
16
17
18
# File 'lib/batch_load/row_parse.rb', line 13

def initialize
  @created      = false
  @parsed       = false
  @parse_errors = []
  @objects      = {}
end

Instance Attribute Details

- (Object) objects

A bucket of all the objects created, indexed by class



10
11
12
# File 'lib/batch_load/row_parse.rb', line 10

def objects
  @objects
end

- (Object) parse_errors

Returns the value of attribute parse_errors



7
8
9
# File 'lib/batch_load/row_parse.rb', line 7

def parse_errors
  @parse_errors
end

- (Object) parsed

Whether the row was parsed or not



5
6
7
# File 'lib/batch_load/row_parse.rb', line 5

def parsed
  @parsed
end

Instance Method Details

- (Array) all_objects

Returns:

  • (Array)


51
52
53
# File 'lib/batch_load/row_parse.rb', line 51

def all_objects
  objects.collect { |type, objs| objs }.flatten
end

- (Array) errored_objects

Returns:

  • (Array)


46
47
48
# File 'lib/batch_load/row_parse.rb', line 46

def errored_objects
  objects.collect { |type, objs| objs.select { |o| !o.valid? } }.flatten
end

- (Boolean) has_errored_objects?

Returns:

  • (Boolean)


41
42
43
# File 'lib/batch_load/row_parse.rb', line 41

def has_errored_objects?
  errored_objects.size > 0
end

- (Boolean) has_object_errors?

Returns:

  • (Boolean)


26
27
28
# File 'lib/batch_load/row_parse.rb', line 26

def has_object_errors?
  objects.select { |o| !o.valid? } > 0
end

- (Boolean) has_parse_errors?

Returns:

  • (Boolean)


21
22
23
# File 'lib/batch_load/row_parse.rb', line 21

def has_parse_errors?
  parse_errors.size > 0
end

- (Boolean) has_persisted_objects?

Returns:

  • (Boolean)


36
37
38
# File 'lib/batch_load/row_parse.rb', line 36

def has_persisted_objects?
  persisted_objects.size > 0
end

- (Boolean) has_valid_objects?

Returns:

  • (Boolean)


61
62
63
# File 'lib/batch_load/row_parse.rb', line 61

def has_valid_objects?
  valid_objects.size > 0
end

- (Array) persisted_objects

Returns:

  • (Array)


31
32
33
# File 'lib/batch_load/row_parse.rb', line 31

def persisted_objects
  objects.collect { |type, objs| objs.select { |o| o.persisted? } }.flatten
end

- (Integer) total_objects

Returns:

  • (Integer)


56
57
58
# File 'lib/batch_load/row_parse.rb', line 56

def total_objects
  all_objects.size
end

- (Array) valid_objects

Returns:

  • (Array)


66
67
68
# File 'lib/batch_load/row_parse.rb', line 66

def valid_objects
  objects.collect { |type, objs| objs.select { |o| o.valid? } }.flatten
end