Sha256: 90fe2715e0d575e29228bd7bd095e6164768347a9be1cf70652f8dfa0c92dcc6

Contents?: true

Size: 459 Bytes

Versions: 8

Compression:

Stored size: 459 Bytes

Contents

module Fish0
  class Collection < Array
    def cache_key
      most_recent = select(&:updated_at).sort_by(&:updated_at).last

      timestamp = time_to_string(most_recent ? most_recent.updated_at : Time.zone.now)

      "#{objects_key}-#{timestamp}"
    end

    protected

    def objects_key
      Digest::MD5.hexdigest(map(&:primary_key_value).join)
    end

    def time_to_string(timestamp)
      timestamp.strftime('%Y%m%d%H%M%S%9N')
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
test_fish0-0.2.0 lib/fish0/collection.rb
fish0-0.2.0 lib/fish0/collection.rb
fish0-0.1.2 lib/fish0/collection.rb
fish0-0.1.1 lib/fish0/collection.rb
fish0-0.1.0 lib/fish0/collection.rb
fish0-0.0.18 lib/fish0/collection.rb
fish0-0.0.17 lib/fish0/collection.rb
fish0-0.0.16 lib/fish0/collection.rb