Skip to content

Commit

Permalink
prefer to use if..end unless the condition is simple/compact
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaydev authored and fxn committed Aug 13, 2011
1 parent 225a248 commit ad9e52f
Showing 1 changed file with 6 additions and 4 deletions.
Expand Up @@ -1143,8 +1143,9 @@ Here's an example where we create a class with an +after_destroy+ callback for a
<ruby>
class PictureFileCallbacks
def after_destroy(picture_file)
File.delete(picture_file.filepath)
if File.exists?(picture_file.filepath)
if File.exists?(picture_file.filepath)
File.delete(picture_file.filepath)
end
end
end
</ruby>
Expand All @@ -1162,8 +1163,9 @@ Note that we needed to instantiate a new +PictureFileCallbacks+ object, since we
<ruby>
class PictureFileCallbacks
def self.after_destroy(picture_file)
File.delete(picture_file.filepath)
if File.exists?(picture_file.filepath)
if File.exists?(picture_file.filepath)
File.delete(picture_file.filepath)
end
end
end
</ruby>
Expand Down

0 comments on commit ad9e52f

Please sign in to comment.