Skip to content

Instantly share code, notes, and snippets.

@collin
Created March 5, 2009 12:53
Show Gist options
  • Select an option

  • Save collin/74343 to your computer and use it in GitHub Desktop.

Select an option

Save collin/74343 to your computer and use it in GitHub Desktop.
class SubjectTweet
include DataMapper::Resource
property :subject_id, Integer, :key => true
property :tweet_id, String, :key => true
property :created_at, DateTime, :index => true
def self.default_storage_name; 'subjects_tweet' end
def find_or_create_for_tweet_and_subject tweet, subject
SubjectTweet.first(:tweet_id => tweet.id, :subject_id => subject.id) ||
SubjectTweet.create(
:tweet_id => tweet.id,
:subject_id => subject.id,
:created_at => tweet.created_at)
end
def self.tweets params
Tweet.get all(params).map{|one| one.tweet_id }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment