Sha256: 5b8adcb2f68fff39bfc8f64e51f4a385261854f9ace10122f17637ea5dd71e8f

Contents?: true

Size: 449 Bytes

Versions: 6

Compression:

Stored size: 449 Bytes

Contents

module MarkMapper
  module Plugins
    module Touch
      extend ActiveSupport::Concern

      def touch(key = :updated_at)
        raise ArgumentError, "Invalid key named #{key}" unless self.key_names.include?(key.to_s)
        if self.class.embeddable?
          self.write_attribute(key, Time.now.utc)
          self._parent_document.touch
        else
          self.set(key => Time.now.utc)
        end
        true
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mark_mapper-0.0.6 lib/mark_mapper/plugins/touch.rb
mark_mapper-0.0.5 lib/mark_mapper/plugins/touch.rb
mark_mapper-0.0.4 lib/mark_mapper/plugins/touch.rb
mark_mapper-0.0.3 lib/mark_mapper/plugins/touch.rb
mark_mapper-0.0.2 lib/mark_mapper/plugins/touch.rb
mark_mapper-0.0.1 lib/mark_mapper/plugins/touch.rb