```ruby

class NilClass
  def method_missing(name, *args, &block)
  end
end

class Sequel::Model
end

class User < Sequel::Model

  plugin :validation_helpers

  def validate
    super
    validates_presence :email
  end

  def before_create
    super
    self.preferences = {:favorites => []}.to_json
    self.token = SecureRandom.hex(32)
    self.created_at = Time.now
    self.updated_at = Time.now
  end

  def before_update
    super
    self.updated_at = Time.now
  end

  def self.find_or_create_by_email(email)
    User.filter(:email => email).first or User.new(:email => email).save
  end

  def add_favorite(uuid)
    preferences = JSON.parse(self.preferences)
    preferences['favorites'].push(uuid).uniq!
    self.preferences = preferences.to_json
    self.save
  end

  def remove_favorite(uuid)
    preferences = JSON.parse(self.preferences)
    preferences['favorites'].delete_if {|f| f === uuid}
    self.preferences = preferences.to_json
    self.save
  end
end
```

Revert "need to parse out preferences before adding/removing favorites"
user
```ruby

class NilClass
  def method_missing(name, *args, &block)
  end
end

class Sequel::Model
end

class User < Sequel::Model

  plugin :validation_helpers

  def validate
    super
    validates_presence :email
  end

  def before_create
    super
    self.preferences = {:favorites => []}.to_json
    self.token = SecureRandom.hex(32)
    self.created_at = Time.now
    self.updated_at = Time.now
  end

  def before_update
    super
    self.updated_at = Time.now
  end

  def self.find_or_create_by_email(email)
    User.filter(:email => email).first or User.new(:email => email).save
  end

  def add_favorite(uuid)
    self.preferences.favorites.push(uuid).uniq!
    self.save
  end

  def remove_favorite(uuid)
    self.preferences.favorites.delete_if {|f| f === uuid}
    self.save
  end
end
```
assistant