Sha256: 7e13a6efb1dc85d2f98be35c8f24c935b0f2b4defb23e2fba9478f93a1794f8f

Contents?: true

Size: 471 Bytes

Versions: 1

Compression:

Stored size: 471 Bytes

Contents

require 'activerecord'
require 'activesupport'

ActiveRecord::Base.class_eval {
  Array.class_eval {
    def cache_key
      if self.empty?
        'empty'
      else
        update_timestamp = max {|a,b| a.updated_at <=> b.updated_at }.updated_at.to_i.to_s
        create_timestamp = max {|a,b| a.created_at <=> b.created_at }.created_at.to_i.to_s
        self.first.class.to_s.underscore+'/'+length.to_s+'-'+create_timestamp+'-'+update_timestamp
      end
    end
  }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
group_cache_key-0.1.0 lib/group_cache_key.rb