houdini/app/models/concerns/model/created_timeable.rb
Eric Schultz 2e8821efdf Initial Transaction and OfflineTransaction support
Co-authored-by: Clarissa Lima Borges <clarissa@commitchange.com>
2021-04-13 10:47:37 -05:00

16 lines
403 B
Ruby

# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
module Model::CreatedTimeable
extend ActiveSupport::Concern
included do
after_initialize :set_created_if_needed
private
def set_created_if_needed
self[:created] = Time.current unless self[:created]
end
end
end