Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
class Module def attribute(name, default=nil, &block) return name.each { |name, default| attribute name, default } if name.is_a? Hash define_method("#{name}=") { |value| instance_variable_set "@#{name}", value } define_method(name) { unless instance_variable_defined? "@#{name}" send "#{name}=", block_given? ? instance_eval(&block) : default end instance_variable_get "@#{name}" } define_method("#{name}?") { not send(name).nil? } end end
This paste will be private.
From the Design Piracy series on my blog: