Skip to content

Instantly share code, notes, and snippets.

@sfgeorge
Created August 18, 2014 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfgeorge/2fe72df83068834d6c1e to your computer and use it in GitHub Desktop.
Save sfgeorge/2fe72df83068834d6c1e to your computer and use it in GitHub Desktop.
punchblock virtus test
# 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