Skip to content

Instantly share code, notes, and snippets.

@pmarreck
Created January 15, 2010 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmarreck/278218 to your computer and use it in GitHub Desktop.
Save pmarreck/278218 to your computer and use it in GitHub Desktop.
class Brand < ActiveRecord::Base
(0..5).each do |f|
define_method("flags_#{f}".to_sym) { read_attribute("flags_#{f}".to_sym).to_2s_complement(64) }
define_method("flags_#{f}=".to_sym){ |n| write_attribute("flags_#{f}".to_sym), n.to_2s_complement(64) }
end
# I'm getting syntax errors in the above code. Not sure why.
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment