Skip to content

Instantly share code, notes, and snippets.

@k2052
Created January 13, 2013 00:36
Show Gist options
  • Save k2052/4521332 to your computer and use it in GitHub Desktop.
Save k2052/4521332 to your computer and use it in GitHub Desktop.
Eva Zebra In Code
class Eva < Zebra
include MongoMapper::Document
include Vegan::Powers
include MongoMapperExt::Taggable
include MongoMapper::Tweetable
## Keys
key :scarves_count, Integer, :default => 20
key :compliments_count, Integer, :default => 100
## Associations
has_many :scarves
has_many :followers
has_many :friends
has_one :macbook
has_one :iphone
belongs_to :earth
## Validations
validates_acceptence_of :all_humans, :self_aware_robots
validates_inclusion_of :nick, :in => :friend_names
validate :scarf_count
validates_presence_of :boobs
validates :drunkness, :if => { ['friday', 'saturday', 'sunday'].include?(Time.today) }
def scarf_count
self.errors.add(:scarves, "Need more scarves") unless self.scarves.count > 10
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment