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.



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

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

Instance Attribute Details

#objectsHash

Returns all the objects created, indexed by class name.

Returns:

  • (Hash)

    all the objects created, indexed by class name



18
19
20
# File 'lib/batch_load/row_parse.rb', line 18

def objects
  @objects
end

#parse_errorsArray

Returns:

  • (Array)


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

def parse_errors
  @parse_errors
end

#parsedBoolean

Returns whether the row was parsed or not.

Returns:

  • (Boolean)

    whether the row was parsed or not



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

def parsed
  @parsed
end

#row_numberInteger

Returns The row this parse is from.

Returns:

  • (Integer)

    The row this parse is from



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

def row_number
  @row_number
end

Instance Method Details

#all_objectsArray

Returns:

  • (Array)


58
59
60
# File 'lib/batch_load/row_parse.rb', line 58

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

#errored_objectsArray

Returns:

  • (Array)


53
54
55
# File 'lib/batch_load/row_parse.rb', line 53

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

#has_errored_objects?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/batch_load/row_parse.rb', line 48

def has_errored_objects?
  errored_objects.size > 0
end

#has_object_errors?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/batch_load/row_parse.rb', line 33

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

#has_parse_errors?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/batch_load/row_parse.rb', line 28

def has_parse_errors?
  parse_errors.size > 0
end

#has_persisted_objects?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/batch_load/row_parse.rb', line 43

def has_persisted_objects?
  persisted_objects.size > 0
end

#has_valid_objects?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/batch_load/row_parse.rb', line 68

def has_valid_objects?
  valid_objects.size > 0
end

#persisted_objectsArray

Returns:

  • (Array)


38
39
40
# File 'lib/batch_load/row_parse.rb', line 38

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

#total_objectsInteger

Returns:

  • (Integer)


63
64
65
# File 'lib/batch_load/row_parse.rb', line 63

def total_objects
  all_objects.size
end

#valid_objectsArray

Returns:

  • (Array)


73
74
75
# File 'lib/batch_load/row_parse.rb', line 73

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