Class: BatchAny::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/batch_any/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#exceptionObject

Returns the value of attribute exception.



3
4
5
# File 'lib/batch_any/item.rb', line 3

def exception
  @exception
end

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/batch_any/item.rb', line 3

def value
  @value
end

Instance Method Details

#fetchObject

Raises:



9
10
11
12
13
14
15
16
17
18
# File 'lib/batch_any/item.rb', line 9

def fetch
  batching_manager = Thread.current[:batch_any_manager]
  if batching_manager
    batching_manager.enqueue_item(self)
  else
    service_class.new(self).fetch
  end
  raise @exception if @exception
  @value
end

#resultObject



20
21
22
23
24
# File 'lib/batch_any/item.rb', line 20

def result
  @value = yield
rescue => e
  @exception = e
end

#service_classObject



5
6
7
# File 'lib/batch_any/item.rb', line 5

def service_class
  raise "Not implemented: #{self.class}#service_class -> Class, required by BatchAny::Item"
end