Last active
August 29, 2015 14:11
-
-
Save solnic/7a39670e0206e6d9d731 to your computer and use it in GitHub Desktop.
Virtus Money EV Example
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
| require 'virtus' | |
| class Money | |
| include Virtus.value_object | |
| values do | |
| attribute :amount, Integer | |
| attribute :currency, String | |
| end | |
| end | |
| class Product | |
| include Virtus.model | |
| attribute :price, Money | |
| end | |
| product = Product.new(price: { amount: 100, currency: 'USD' }) | |
| puts product.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment