Class: Workarea::BulkAction::SequentialProductEdit

Inherits:
Workarea::BulkAction show all
Defined in:
app/models/workarea/bulk_action/sequential_product_edit.rb

Instance Method Summary collapse

Methods inherited from Workarea::BulkAction

#admin_query, #completed!, #completed?, #convert_query_to_ids, #perform!, #reset_to_default!

Methods included from ApplicationDocument

#releasable?

Methods included from Sidekiq::Callbacks

assert_valid_config!, async, disable, enable, inline, #run_callbacks

Methods included from Mongoid::Document

#embedded_children

Instance Method Details

#act_on!(product) ⇒ Object

It’s ok to override here, since this BulkAction doesn’t really have a chunk of work to do for each product - it’s up to the administrator.



14
15
16
17
18
# File 'app/models/workarea/bulk_action/sequential_product_edit.rb', line 14

def act_on!(product)
  @current_index ||= 0
  throw :matching_index, product if @current_index == @seeking_index
  @current_index += 1
end

#find_product(index) ⇒ Object

Good god is this gnarly, but the amount of code to do this better would be very large.



6
7
8
9
10
# File 'app/models/workarea/bulk_action/sequential_product_edit.rb', line 6

def find_product(index)
  @current_index = 0
  @seeking_index = index.to_i
  catch(:matching_index) { perform! }
end