30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/virtual_date.rb', line 30
def act_as_virtual_date(*attributes)
opts = VirtualDate.get_options(attributes)
defined_format = opts ? opts[:format] : nil
attributes.each do |attribute|
define_method "#{attribute.to_s}_str=" do |arg|
send("#{attribute.to_s}=", VirtualDate.to_date(arg))
end
define_method "#{attribute.to_s}_str" do |*args|
VirtualDate.date_format send("#{attribute.to_s}"), (args[0] || defined_format || VirtualDate.format)
end
end
end
|