Module: CoreExt::BooleanAccessor
- Defined in:
- lib/core_ext/module/boolean_accessor.rb
Instance Method Summary collapse
Instance Method Details
#boolean_accessor(*syms) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/core_ext/module/boolean_accessor.rb', line 3 def boolean_accessor(*syms) syms.each do |sym| class_eval(" def \#{sym}?; @\#{sym} == 1; end\n def \#{sym}=(value); @\#{sym} = value.to_s.match(/true|yes|on|1/i) ? 1 : 0; end\n def \#{sym}; @\#{sym}; end\n EOS\n end\nend\n", __FILE__, __LINE__) |