Skip to content

Instantly share code, notes, and snippets.

@cdl
Forked from k2052/Eva.rb
Last active December 11, 2015 01:09
Show Gist options
  • Save cdl/4521396 to your computer and use it in GitHub Desktop.
Save cdl/4521396 to your computer and use it in GitHub Desktop.
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
key :hivemind_response_count, Integer, :default => 500
## Associations
has_many :scarves
has_many :tweets, :followers, :mentions
has_many :friends, :creeps
has_one :tattoo # I think?
has_one :macbook
has_one :iphone
has_one :boyfriend
belongs_to :earth
## Validations
validates_acceptence_of :all_humans, :self_aware_robots, :bowties
validates_inclusion_of :nick, :in => :friend_names
validates_inclusion_of :tim, :in => :lover_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
def hivemind_response_count
self.errors.add(:tweets, "NEED MORE HIVEMIND RESPONSES") unless self.mentions.count > 100
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment