Created
July 7, 2009 15:42
-
-
Save arunthampi/142165 to your computer and use it in GitHub Desktop.
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
class Person < SuperModel::Base | |
# If you don't specify a 'type', it defaults to string</span> | |
# while converting to JSON | |
has :name | |
end | |
# Create a SuperModel object | |
p = Person.new(:name => 'McLovin') | |
# Another way you can create a SuperModel object | |
p1 = Person.new do |person| | |
person.name = 'Seth' | |
end | |
# JSON serialization | |
p.to_json # => {"name":"McLovin"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment