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

#initializeRowParse

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

#objectsObject

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

#parse_errorsObject

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

#parsedObject

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

#all_objectsArray

Returns:

  • (Array)


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

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

#errored_objectsArray

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

#has_errored_objects?Boolean

Returns:

  • (Boolean)


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

def has_errored_objects?
  errored_objects.size > 0
end

#has_object_errors?Boolean

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

#has_parse_errors?Boolean

Returns:

  • (Boolean)


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

def has_parse_errors?
  parse_errors.size > 0
end

#has_persisted_objects?Boolean

Returns:

  • (Boolean)


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

def has_persisted_objects?
  persisted_objects.size > 0
end

#has_valid_objects?Boolean

Returns:

  • (Boolean)


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

def has_valid_objects?
  valid_objects.size > 0
end

#persisted_objectsArray

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

#total_objectsInteger

Returns:

  • (Integer)


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

def total_objects
  all_objects.size
end

#valid_objectsArray

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