-
-
Save pushcx/7a518425daf0f7b1907b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
entity = Node.new(id: id) | |
case | |
when not enity.exists? then fail("Entity doesn't exist") | |
when not entity.file? then fail("Entity wasn't a file") | |
when not entity.writable? then fail("Entity wasn't writable") | |
else entity.write(data) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
entity = Node.new(id: id) | |
if enity.exists? && entity.file? && entity.writable? | |
entity.write(data) | |
else | |
fail("Entity doesn't exist") unless entity.exists? | |
fail("Entity wasn't a file") unless entity.file? | |
fail("Entity wasn't writable") unless entity.writable? | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
entity = Node.new(id: id) | |
class Node | |
def write(data) | |
fail("Entity doesn't exist") unless exists? | |
fail("Entity wasn't a file") unless file? | |
fail("Entity wasn't writable") unless writable? | |
# usual write work | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment