Class: BatchLoad::RowParse
- Inherits:
-
Object
- Object
- BatchLoad::RowParse
- Defined in:
- lib/batch_load/row_parse.rb
Overview
The result of parsing a row.
Instance Attribute Summary collapse
-
#objects ⇒ Hash
All the objects created, indexed by class name.
- #parse_errors ⇒ Array
-
#parsed ⇒ Boolean
Whether the row was parsed or not.
-
#row_number ⇒ Integer
The row this parse is from.
Instance Method Summary collapse
- #all_objects ⇒ Array
- #errored_objects ⇒ Array
- #has_errored_objects? ⇒ Boolean
- #has_object_errors? ⇒ Boolean
- #has_parse_errors? ⇒ Boolean
- #has_persisted_objects? ⇒ Boolean
- #has_valid_objects? ⇒ Boolean
-
#initialize ⇒ RowParse
constructor
A new instance of RowParse.
- #persisted_objects ⇒ Array
- #total_objects ⇒ Integer
- #valid_objects ⇒ Array
Constructor Details
#initialize ⇒ RowParse
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
#objects ⇒ Hash
Returns 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_errors ⇒ Array
14 15 16 |
# File 'lib/batch_load/row_parse.rb', line 14 def parse_errors @parse_errors end |
#parsed ⇒ Boolean
Returns whether the row was parsed or not.
11 12 13 |
# File 'lib/batch_load/row_parse.rb', line 11 def parsed @parsed end |
#row_number ⇒ Integer
Returns 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_objects ⇒ 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_objects ⇒ 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
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
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
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
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
68 69 70 |
# File 'lib/batch_load/row_parse.rb', line 68 def has_valid_objects? valid_objects.size > 0 end |
#persisted_objects ⇒ 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_objects ⇒ Integer
63 64 65 |
# File 'lib/batch_load/row_parse.rb', line 63 def total_objects all_objects.size end |
#valid_objects ⇒ 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 |