Sha256: eefdc92008477f2afb8cf14f23d8dd308127193b5597629c37eb98cf8b8adb3f

Contents?: true

Size: 446 Bytes

Versions: 10

Compression:

Stored size: 446 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(&:slug).join)
    end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fish0-0.0.15 lib/fish0/collection.rb
fish0-0.0.14 lib/fish0/collection.rb
fish0-0.0.13 lib/fish0/collection.rb
fish0-0.0.12 lib/fish0/collection.rb
fish0-0.0.11 lib/fish0/collection.rb
fish0-0.0.10 lib/fish0/collection.rb
fish0-0.0.9 lib/fish0/collection.rb
fish0-0.0.8 lib/fish0/collection.rb
fish0-0.0.7 lib/fish0/collection.rb
fish0-0.0.6 lib/fish0/collection.rb