Skip to content

Instantly share code, notes, and snippets.

@jackprophesy
Created October 8, 2009 05:30
Show Gist options
  • Save jackprophesy/204779 to your computer and use it in GitHub Desktop.
Save jackprophesy/204779 to your computer and use it in GitHub Desktop.
module Passion
module Contact
module Timeline
# Add universal "columns" to the model
def self.included(base)
base.send :key, :contact_id, String
base.send :key, :timeline_at, Time
base.extend ClassMethods
end
module ClassMethods
attr :summary
def add_to_timeline(options = {})
@summary = options[:summary]
puts "Summary set: " + @summary
end
end
def after_save
Feed.create(:summary => "buddy", :contact_id => self.contact_id, :type => self.class, :type_id => self.id)
end
def after_destory
puts 'DESTROY ' + self.class.to_s + self.id.to_s
Feed.all(:conditions => {:type => self.class, :type_id => self.id}).each {|a| a.destroy }
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment