Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/fuzzy_date.rb
Class Method Summary collapse
Class Method Details
.acts_as_fuzzy_date(*args) ⇒ Object
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/fuzzy_date.rb', line 283 def acts_as_fuzzy_date(*args) args.each do |name| str =<<-EOF def #{name} FuzzyDate.new_from_db(self['#{name}']) end def #{name}=(s) if s.kind_of? String self['#{name}'] = FuzzyDate.parse(s).to_db unless s.strip.empty? elsif s.kind_of? FuzzyDate self['#{name}']=s.to_db elsif !s self['#{name}'] = nil end end EOF class_eval str end end |