This project is archived and is in readonly mode.
boolean_attr_accessor
-
Rohit Arondekar
- Importance changed from to Low
Mark, I think you should also post on the core list: http://groups.google.com/group/rubyonrails-core You'll get more responses there as to whether this is a desired feature or not.
-
Robert Pankowecki
- Tag changed from activesupport, attr_accessor, core_ext, patch to activesupport, attr_accessor, boolean, core_ext, patch
I use such code for this:
module Kernel def Boolean(b) return b if [FalseClass, TrueClass, NilClass].any?{|k| b.is_a?(k)} case b when /^1$/, /^true$/i , /^yes$/i then true when /^0$/, /^false$/i , /^no$/i then false else raise ArgumentError, "Unknown conversion to boolean type from: #{b.class}, Inspect: #{b.inspect}" end end end def bar=(value) write_attribute(:bar, Boolean(value)) end -
Gaston Ramos
I like the idea, but I'm not sure if it is right to take a lot of values as false
-
Aditya Sanghi
You may want to make this a plugin first? If it's a really popular plugin, perhaps it will get included in the future.
