At the moment we’re holding whiteboards as a serialised field in
contents table. Which was fine when we were also caching the HTML
representations there too – whiteboards generally got (re)generated
during text formatting and got magically saved along with the html
renderings.
But now, the rendered html is managed by the controller and held in
a different sort of cache, so the article doesn’t get saved, so the
whiteboard data gets thrown away. Which is not good.
So, my thinking is add something like:
class Whiteboard
serialize :data
def method_missing(:method, *args)
method.to_s =~ /^(.*)(=?)$/
key = $1
is_assignment = !$2.blank?
unless data.has_key? key
return super(:method, *args)
end
if is_assignment
data[key] = *args
else
data[key]
end
end
end
And having a table definition like
create_table :whiteboards do |t|
t.column :name, :string
t.column :data, :text
end
The tricky part might be in getting a working acts_as_hash
implementation, but that’s a SMOP.
Thoughts?