Class: Auctify::BidderRegistration

Inherits:
ApplicationRecord show all
Includes:
AASM
Defined in:
app/models/auctify/bidder_registration.rb

Instance Method Summary collapse

Instance Method Details

#fillup_autobid_flags!Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/models/auctify/bidder_registration.rb', line 54

def fillup_autobid_flags!
  current_limit = 0
  ordered_applied_bids.reverse_each do |bid|
    if bid.with_limit?
      if current_limit < bid.limit
        # increase of limit
        bid.autobid = false
        current_limit = bid.limit
      else
        # same limit, same registration, younger bid => autobid
        bid.autobid = true
      end
    else
      bid.autobid = false
    end
    bid.save!(validate: false)
  end
end