Created
May 17, 2010 18:33
-
-
Save sinefunc/404075 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
class Post < Ohm::Model | |
include Ohm::Typecast | |
attribute :price, Decimal | |
end | |
post = Post.new(:price => "FooBar") | |
post.price == "FooBar" | |
# => true | |
post.valid? | |
# raises Ohm::Typecast::MissingValidation, with message to add an assert_type_decimal :price" | |
class Post | |
def validate | |
assert_type_decimal :price | |
end | |
end | |
post = Post.new(:price => "FooBar") | |
post.valid? | |
post.errors == [[:price, :not_decimal]] | |
# => true | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment