Sha256: dd416560d233a58936946e1ffa61b776a33294fdcff310ef3d934668592617e5
Contents?: true
Size: 526 Bytes
Versions: 1
Compression:
Stored size: 526 Bytes
Contents
require 'rails' require 'time_for_a_boolean/version' require 'time_for_a_boolean/railtie' module TimeForABoolean def time_for_a_boolean(attribute) define_method(attribute) do !send("#{attribute}_at").nil? && send("#{attribute}_at") <= -> { DateTime.now }.() end alias_method "#{attribute}?", attribute define_method("#{attribute}=") do |value| if value send("#{attribute}_at=", -> { DateTime.now }.()) else send("#{attribute}_at=", nil) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
time_for_a_boolean-0.0.2 | lib/time_for_a_boolean.rb |