Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save collin/74342 to your computer and use it in GitHub Desktop.
class Tweet
attr_accessor :data
def self.cabinet
@cabinet ||= Moneta::Rufus.new()
end
def cabinet; self.class.cabinet end
def self.new data
super(data)
end
def self.create data
tweet = new(data)
tweet.save
tweet
end
def initialize data
self.data = data
end
def save
self.data["source"] ||= "<a href="http://twitter.com">web</a>"
self.data["found_at"] = Time.now
cabinet[self.id] = self.data
end
def self.get ids
if ids.is_a? Array
ids.map{|id| construct cabinet[id] }.compact
else
construct cabinet[ids]
end
end
def self.construct data
return nil unless data
new data
end
def id
data["id"].to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment