Skip to content

Commit

Permalink
Refactor WebsiteAgent::store_payload!
Browse files Browse the repository at this point in the history
This is to avoid a jump (return) from within a block where possible.
  • Loading branch information
knu committed Apr 30, 2015
1 parent a434315 commit 847282f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/models/agents/website_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,12 @@ def store_payload!(old_events, result)
case interpolated['mode'].presence
when 'on_change'
result_json = result.to_json
old_events.each do |old_event|
if old_event.payload.to_json == result_json
old_event.expires_at = new_event_expiration_date
old_event.save!
return false
end
if found = old_events.find { |event| event.payload.to_json == result_json }
found.update!(expires_at: new_event_expiration_date)
false
else
true
end
true
when 'all', 'merge', ''
true
else
Expand Down

0 comments on commit 847282f

Please sign in to comment.