Sha256: f1a7706766ed3217f9fefbcc6189fea76cdf37ae8365befdb0bd39ff51cda2dc

Contents?: true

Size: 367 Bytes

Versions: 8

Compression:

Stored size: 367 Bytes

Contents

module Dolly
  module Timestamps

    def timestamps!
      property :created_at, :updated_at, class_name: Time

      self.timestamps[self.name] = true

      self.class_eval do

        def set_created_at
          doc['created_at'] ||= Time.now
        end

        def set_updated_at
          doc['updated_at'] = Time.now
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dolly-1.1.7 lib/dolly/timestamps.rb
dolly-1.1.6 lib/dolly/timestamps.rb
dolly-1.1.5 lib/dolly/timestamps.rb
dolly-1.1.4 lib/dolly/timestamps.rb
dolly-1.1.3 lib/dolly/timestamps.rb
dolly-1.1.2 lib/dolly/timestamps.rb
dolly-1.1.1 lib/dolly/timestamps.rb
dolly-1.1.0 lib/dolly/timestamps.rb