Created
October 21, 2012 08:39
-
-
Save priyaaank/3926360 to your computer and use it in GitHub Desktop.
Models for Modular API with Grape and Rails
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 ContactInfo | |
| include Mongoid::Document | |
| field :address_line, :type => String | |
| field :city, :type => String | |
| field :country, :type => String | |
| field :zipcode, :type => String | |
| field :state, :type => String | |
| embeds_many :phone_numbers | |
| end |
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 PhoneNumber | |
| include Mongoid::Document | |
| field :country_code, :type => String | |
| field :area_code, :type => String | |
| field :number, :type => String | |
| def formatted_number | |
| ["+"+country_code,area_code,number].join("-") | |
| end | |
| end |
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 User | |
| include Mongoid::Document | |
| field :first_name, :type => String | |
| field :last_name, :type => String | |
| field :email, :type => String | |
| field :username, :type => String | |
| embeds_one :contact_info | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment