class PIM::ItemsWithPostExhaustionDeadline
Enumerable wrapper that calls {PIM.limit_execution} once the underlying items collection has been fully consumed (not on early break / early iterator stop). Used by {Exporter} so post-item work (PDF/FOP, zip, …) still has a wall-clock budget.
Also exposes iterator so Java APIs such as {PIM::Services::ItemService.convert_items_to_xml} / +Iterable#iterator+ keep working (demomodel +items_as_xml(items)+ path).
Constants
- POST_EXHAUSTION_DEADLINE_REASON_MESSAGE
Public Class Methods
new(items, deadline_seconds)
click to toggle source
# File exporter.rb, line 30 def initialize(items, deadline_seconds) @items = items @deadline_seconds = deadline_seconds @deadline_applied = false end
wrap(items, deadline_seconds)
click to toggle source
# File exporter.rb, line 25 def self.wrap(items, deadline_seconds) return items if items.nil? || items.is_a?(ItemsWithPostExhaustionDeadline) new(items, deadline_seconds) end
Public Instance Methods
each(&block)
click to toggle source
# File exporter.rb, line 36 def each(&block) return enum_for(:each) unless block_given? @items.each(&block) apply_deadline self end
iterator()
click to toggle source
Java +Iterable#iterator+ entry point. Exhaustion (not early stop) applies the same post-item deadline as {#each}.
# File exporter.rb, line 47 def iterator PostExhaustionIterator.new(delegate_iterator, method(:apply_deadline)) end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File exporter.rb, line 51 def method_missing(name, *args, &block) return @items.public_send(name, *args, &block) if @items.respond_to?(name) super end
respond_to_missing?(name, include_private = false)
click to toggle source
Calls superclass method
# File exporter.rb, line 56 def respond_to_missing?(name, include_private = false) @items.respond_to?(name, include_private) || super end