Sha256: 59260b31e90b7303e64b1982d97c4d819da36818ac1d4948173febc25dbea4a5

Contents?: true

Size: 291 Bytes

Versions: 4

Compression:

Stored size: 291 Bytes

Contents

module Rostra
  module TimestampObserver

    def self.included(base)
      base.after_save :set_active_at
    end

    private

    def set_active_at
      question = self.is_a?(Rostra::Question) ? self : self.question
      question.update_attribute(:active_at, Time.now)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rostra-0.1.24 lib/rostra/timestamp_observer.rb
rostra-0.1.23 lib/rostra/timestamp_observer.rb
rostra-0.1.22 lib/rostra/timestamp_observer.rb
rostra-0.1.21 lib/rostra/timestamp_observer.rb