Class: BatchLoad::ColumnResolver::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/batch_load/column_resolver/result.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Ignored) initialize



20
21
22
23
# File 'lib/batch_load/column_resolver/result.rb', line 20

def initialize
  @error_messages = []
  @items = []
end

Instance Attribute Details

- (Object) error_messages

When the resolver can not identify a single record the reasons can be added here



17
18
19
# File 'lib/batch_load/column_resolver/result.rb', line 17

def error_messages
  @error_messages
end

- (Object) item

The singular resolved item



8
9
10
# File 'lib/batch_load/column_resolver/result.rb', line 8

def item
  @item
end

- (Object) items

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.



13
14
15
# File 'lib/batch_load/column_resolver/result.rb', line 13

def items
  @items
end

Instance Method Details

- (Array) assign(objects)

Parameters:

  • objects (Object)

Returns:

  • (Array)


42
43
44
45
46
47
48
49
50
51
52
# File 'lib/batch_load/column_resolver/result.rb', line 42

def assign(objects)
  if objects.class == Array
    if objects.size == 1
      @item = objects.first
    else
      @items = objects
    end
  else
    @item = objects
  end
end

- (Boolean) multiple_matches?

Returns:

  • (Boolean)


31
32
33
# File 'lib/batch_load/column_resolver/result.rb', line 31

def multiple_matches?
  items.size > 0
end

- (Boolean) no_matches?

Returns:

  • (Boolean)


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

def no_matches?
  item.nil? and items.empty?
end

- (Boolean) resolvable?

Returns:

  • (Boolean)


26
27
28
# File 'lib/batch_load/column_resolver/result.rb', line 26

def resolvable?
  item && error_messages.size == 0 && items == [] # a little redundant, but keep it safe
end