Sha256: bc503edcc19e9bc3b07e569594f996d2e6fdac5acc0a3bbf7c01dc180a6f691a

Contents?: true

Size: 711 Bytes

Versions: 9

Compression:

Stored size: 711 Bytes

Contents

# frozen_string_literal: true

class Roda
  module Endpoints
    # Generic HTTP endpoint abstraction.
    class Endpoint
      # Accessing data inside of endpoint.
      module Caching
        # @param last_modified [Symbol]
        # @param attributes [{Symbol=>Object}]
        def initialize(last_modified: Undefined, **attributes)
          @last_modified = last_modified unless last_modified == Undefined
          super(**attributes)
        end

        # @return [Time]
        def last_modified
          Time.now
        end

        # @return [{Symbol=>Object}]
        def to_hash
          @last_modified ? super.merge(last_modified: @last_modified) : super
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
roda-endpoints-0.3.6 lib/roda/endpoints/endpoint/caching.rb
roda-endpoints-0.3.5 lib/roda/endpoints/endpoint/caching.rb
roda-endpoints-0.3.4 lib/roda/endpoints/endpoint/caching.rb
roda-endpoints-0.3.3 lib/roda/endpoints/endpoint/caching.rb
roda-endpoints-0.3.2 lib/roda/endpoints/endpoint/caching.rb
roda-endpoints-0.3.1 lib/roda/endpoints/endpoint/caching.rb
roda-endpoints-0.3.0 lib/roda/endpoints/endpoint/caching.rb
roda-endpoints-0.2.0 lib/roda/endpoints/endpoint/caching.rb
roda-endpoints-0.1.0 lib/roda/endpoints/endpoint/caching.rb