Skip to content

Instantly share code, notes, and snippets.

@Dishwasha
Created March 10, 2010 14:06
Show Gist options
  • Save Dishwasha/327891 to your computer and use it in GitHub Desktop.
Save Dishwasha/327891 to your computer and use it in GitHub Desktop.
class HashRowColumn
include MongoMapper::Document
key :row, String
key :column, Hash
key :column_ids, Array
def self.[](r = nil)
return HashRowColumns if(r.nil?)
hr = HashRowColumn.find_by_row(r)
if(hr)
hr
else
HashRowColumn.create!(:row => r)
end
end
def []=(c,value)
column[c] = value
column_ids << c
save
end
end
class HashRowColumns
def self.[](c)
HashRowColumn.all(:conditions => {:column_ids => c})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment