BlankSlate: Clean an object class to its bare minimum methods in Ruby
class BlankSlate instance_methods.each { |m| undef_method m unless m =~ /^__/ } end
DZone Snippets > peter > classes
12158 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Peter Cooperx http://www.petercooper.co.uk/
class BlankSlate instance_methods.each { |m| undef_method m unless m =~ /^__/ } end
class Song < ActiveRecord::Base # Uses an integer of seconds to hold the length of the song def length=(minutes) write_attribute("length", minutes * 60) end def length read_attribute("length") / 60 end end