Skip to content

Instantly share code, notes, and snippets.

@arunthampi
Created July 7, 2009 15:42
Show Gist options
  • Save arunthampi/142165 to your computer and use it in GitHub Desktop.
Save arunthampi/142165 to your computer and use it in GitHub Desktop.
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