Sha256: 087b98480ef83c99f5b15c5e4a36b14f2003189a3e53d4d832316ef610f76b36
Contents?: true
Size: 633 Bytes
Versions: 1
Compression:
Stored size: 633 Bytes
Contents
require 'active_record/connection_adapters/column' 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 ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(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.4 | lib/time_for_a_boolean.rb |