Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
module MetaSkills def attribute_accessor(name) attribute_reader(name) attribute_writer(name) end def attribute_reader(name) define_method(name) do instance_variable_get "@#{name}" end end def attribute_writer(name) define_method "#{name}=" do |value| instance_variable_set "@#{name}", value end end end Class.instance_eval do include MetaSkills end class MyClass attribute_accessor :foo end o = MyClass.new o.foo # => nil o.foo = 'bar' # => "bar" o # => #<MyClass:0x1001722c0 @foo="bar">
This paste will be private.
From the Design Piracy series on my blog: