Created
March 5, 2009 12:50
-
-
Save collin/74342 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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