Skip to content

Instantly share code, notes, and snippets.

@jwaldrip
Last active December 17, 2015 16:29
Show Gist options
  • Save jwaldrip/5639489 to your computer and use it in GitHub Desktop.
Save jwaldrip/5639489 to your computer and use it in GitHub Desktop.
class FeedItem < ActiveRecord::Base
# hstore is data
def self.field(name)
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{name}=(val)
self.data[:#{name}] = val
end
def #{name}
self.data[:#{name}]
end
RUBY
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment