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 not



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

def parsed
  @parsed
end

Instance Method Details

- (Object) all_objects



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

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

- (Object) errored_objects



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

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

- (Boolean) has_errored_objects?

Returns:

  • (Boolean)


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

def has_errored_objects?
  errored_objects.size > 0
end

- (Boolean) has_object_errors?

Returns:

  • (Boolean)


24
25
26
# File 'lib/batch_load/row_parse.rb', line 24

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

- (Boolean) has_parse_errors?

Returns:

  • (Boolean)


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

def has_parse_errors?
  parse_errors.size > 0
end

- (Boolean) has_persisted_objects?

Returns:

  • (Boolean)


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

def has_persisted_objects?
  persisted_objects.size > 0
end

- (Boolean) has_valid_objects?

Returns:

  • (Boolean)


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

def has_valid_objects?
  valid_objects.size > 0
end

- (Object) persisted_objects



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

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

- (Object) total_objects



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

def total_objects
  all_objects.size
end

- (Object) valid_objects



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

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