2017-10-13 130 views
0

我有一個不純的功能,像這樣:YARD:文檔無用的或無意的回報

# Impure function: Sets the status for a report_schedule, uses last_sent to 
# calculate status 
# @param report_schedule [Hash] 
# @return [String] Non-useful: value of last_sent that was set 
def self.set_report_schedule_status(report_schedule) 
    # Some logic that calculates status of report_schedule 
    report_schedule['status'] = status 
    report_schedule['last_sent'] = Time.now.to_s 
end 

我要的這個功能做的是建立statuslast_sent,但這裏的副作用是,它返回Time.now.to_s 。有沒有合適的方法來記錄這一點? 或者是我的函數定義錯誤或應該以return nil結尾。

回答

0

應該只是增加return nil

紅寶石自動追加返回的方法執行的最後一件事