Sha256: cfef2a7bdf7cbcea6ad72885d2f4f4e0551b28938e9ac5733d59f220f34ec6a3
Contents?: true
Size: 534 Bytes
Versions: 1
Compression:
Stored size: 534 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.current }.() end alias_method "#{attribute}?", attribute define_method("#{attribute}=") do |value| if value send("#{attribute}_at=", -> { DateTime.current }.()) 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.3 | lib/time_for_a_boolean.rb |