Class: BatchLoad::ColumnResolver::Result
- Inherits:
-
Object
- Object
- BatchLoad::ColumnResolver::Result
- Defined in:
- lib/batch_load/column_resolver/result.rb
Instance Attribute Summary collapse
-
#error_messages ⇒ Object
When the resolver can not identify a single record the reasons can be added here.
-
#item ⇒ Object
The singular resolved item.
-
#items ⇒ Object
When more than one item is found they are listed here.
Instance Method Summary collapse
- #assign(objects) ⇒ Array
-
#initialize ⇒ Result
constructor
A new instance of Result.
- #multiple_matches? ⇒ Boolean
- #no_matches? ⇒ Boolean
- #resolvable? ⇒ Boolean
Constructor Details
#initialize ⇒ Result
Returns a new instance of Result.
18 19 20 21 |
# File 'lib/batch_load/column_resolver/result.rb', line 18 def initialize @error_messages = [] @items = [] end |
Instance Attribute Details
#error_messages ⇒ Object
When the resolver can not identify a single record the reasons can be added here
16 17 18 |
# File 'lib/batch_load/column_resolver/result.rb', line 16 def @error_messages end |
#item ⇒ Object
The singular resolved item
7 8 9 |
# File 'lib/batch_load/column_resolver/result.rb', line 7 def item @item end |
#items ⇒ Object
When more than one item is found they are listed here. In practice this should be limited to the first 10 or so, rather than all potential matches.
12 13 14 |
# File 'lib/batch_load/column_resolver/result.rb', line 12 def items @items end |
Instance Method Details
#assign(objects) ⇒ Array
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/batch_load/column_resolver/result.rb', line 40 def assign(objects) if objects.class == Array if objects.size == 1 @item = objects.first @items = [] else @items = objects @item = nil end else @item = objects end end |
#multiple_matches? ⇒ Boolean
29 30 31 |
# File 'lib/batch_load/column_resolver/result.rb', line 29 def multiple_matches? items.size > 0 end |
#no_matches? ⇒ Boolean
34 35 36 |
# File 'lib/batch_load/column_resolver/result.rb', line 34 def no_matches? item.nil? and items.empty? end |
#resolvable? ⇒ Boolean
24 25 26 |
# File 'lib/batch_load/column_resolver/result.rb', line 24 def resolvable? item && .size == 0 && items == [] # a little redundant, but keep it safe end |