Created
March 1, 2010 22:19
-
-
Save yannick/318877 to your computer and use it in GitHub Desktop.
This file contains 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 Code < Ohm::Model | |
include Comparable | |
attribute :sha1 | |
attribute :md5 | |
attribute :filesize | |
attribute :mimetype | |
set :filenames | |
counter :votes | |
index :sha1 | |
def filename=(filename) | |
@filename = filename | |
end | |
def filename | |
@filename | |
end | |
def create | |
return unless valid? | |
initialize_id | |
#TODO: hack to put a new filename into the set | |
filenames << @filename | |
mutex do | |
create_model_membership | |
write | |
add_to_indices | |
end | |
end | |
private | |
def initialize_id | |
self.id = self.sha1 | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment