Created
August 18, 2014 15:14
-
-
Save sfgeorge/2fe72df83068834d6c1e to your computer and use it in GitHub Desktop.
punchblock virtus test
This file contains hidden or 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
# https://www.youtube.com/watch?v=JmzuRXLzqKk | |
class Output | |
include Virtus | |
attribute :render_documents, String | |
def render_document=(other) | |
puts "Reached render_document=(#{other.inspect})" | |
puts " render_documents before: #{render_documents.inspect}" | |
self.render_documents = [other].compact | |
puts " render_documents after: #{render_documents.inspect}" | |
end | |
end | |
# Cat's Win! | |
output = Output.new(render_document: "Dogs", render_documents: "Cats") | |
puts "final render_documents: #{output.render_documents.inspect}" | |
# Cats Lose! | |
output = Output.new(render_documents: "Cats", render_document: "Dogs") | |
puts "final render_documents: #{output.render_documents.inspect}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment