Sha256: d60d3025eb69f24564234a7ab3fb20dfea60075493763925e3f4e6eebd68a5b9

Contents?: true

Size: 632 Bytes

Versions: 10

Compression:

Stored size: 632 Bytes

Contents

module ZTK::DSL::Core::Actions

  # @author Zachary Patten <zpatten AT jovelabs DOT io>
  # @api private
  module Timestamps

    def self.included(base)
      base.class_eval do
        base.send(:extend, ZTK::DSL::Core::Actions::Timestamps::ClassMethods)
      end
      base.instance_eval do
        attribute :created_at
        attribute :updated_at
      end
    end

    # @author Zachary Patten <zpatten AT jovelabs DOT io>
    module ClassMethods

      def updated_at_timestamp
        self.updated_at = Time.now
      end

      def created_at_timestamp
        self.created_at ||= Time.now
      end

    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ztk-3.3.2 lib/ztk/dsl/core/actions/timestamps.rb
ztk-3.3.1 lib/ztk/dsl/core/actions/timestamps.rb
ztk-3.3.0 lib/ztk/dsl/core/actions/timestamps.rb
ztk-3.2.6 lib/ztk/dsl/core/actions/timestamps.rb
ztk-3.2.5 lib/ztk/dsl/core/actions/timestamps.rb
ztk-3.2.4 lib/ztk/dsl/core/actions/timestamps.rb
ztk-3.2.3 lib/ztk/dsl/core/actions/timestamps.rb
ztk-3.2.2 lib/ztk/dsl/core/actions/timestamps.rb
ztk-3.2.1 lib/ztk/dsl/core/actions/timestamps.rb
ztk-3.2.0 lib/ztk/dsl/core/actions/timestamps.rb