Class: Auctify::BidsAppender

Inherits:
ServiceBase show all
Defined in:
app/services/auctify/bids_appender.rb

Instance Attribute Summary collapse

Attributes inherited from ServiceBase

#errors, #flashes, #result

Instance Method Summary collapse

Methods inherited from ServiceBase

call, #call, #fail!, #failure?, #success?

Constructor Details

#initialize(auction:, bid: nil) ⇒ BidsAppender

Returns a new instance of BidsAppender.



7
8
9
10
11
12
# File 'app/services/auctify/bids_appender.rb', line 7

def initialize(auction:, bid: nil)
  super()

  @auction = auction
  @bid = bid
end

Instance Attribute Details

#auctionObject (readonly)

Returns the value of attribute auction.



5
6
7
# File 'app/services/auctify/bids_appender.rb', line 5

def auction
  @auction
end

#bidObject (readonly)

Returns the value of attribute bid.



5
6
7
# File 'app/services/auctify/bids_appender.rb', line 5

def bid
  @bid
end

Instance Method Details

#build_resultObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/services/auctify/bids_appender.rb', line 14

def build_result
  self.current_price = auction.current_price
  @updated_win_bid = nil

  if bid
    set_price_for_limit_bid

    if approved_bid?
      solve_winner(winning_bid, bid)
      append_bids!
      update_auction! unless failed?
    else
      fail!
    end
  end

  @result = result_struct
end