Sha256: 25a107bd710a0cce9cfd14d4b3ac76ef7748e3ef15d95e8aca813c53e05a36be

Contents?: true

Size: 834 Bytes

Versions: 19

Compression:

Stored size: 834 Bytes

Contents

module Stitches
  module Deprecation
    # Indicate that a previously-deprecated endpoint is now gone
    def gone!
      head 410
    end

    # Indicate that this endpoint is deprecated and will go away on the given date.
    #
    # gon_on: - date, as a string, when this endpoint will go away
    # block - the contents of the endpoint
    #
    # Example:
    #
    #     def show
    #       deprecated gone_on: "2019-04-09" do
    #         render widgets: { Widget.find(params[:id]) }
    #       end
    #     end
    def deprecated(gone_on:,&block)
      response.set_header("Sunset",Date.parse(gone_on).in_time_zone("GMT").midnight.strftime("%a, %e %b %Y %H:%M:%S %Z"))
      Rails.logger.info("DEPRECATED ENDPOINT #{request.method} to #{request.fullpath} requested by #{current_user.id}")
      block.()
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
stitches-5.0.0 lib/stitches/deprecation.rb
stitches-5.0.0.RC1 lib/stitches/deprecation.rb
stitches-4.2.2 lib/stitches/deprecation.rb
stitches-4.2.1 lib/stitches/deprecation.rb
stitches-4.2.0 lib/stitches/deprecation.rb
stitches-4.2.0.RC3 lib/stitches/deprecation.rb
stitches-4.2.0.RC2 lib/stitches/deprecation.rb
stitches-4.2.0.RC1 lib/stitches/deprecation.rb
stitches-4.0.2 lib/stitches/deprecation.rb
stitches-4.1.0RC2 lib/stitches/deprecation.rb
stitches-4.0.1 lib/stitches/deprecation.rb
stitches-4.0.0 lib/stitches/deprecation.rb
stitches-4.0.0.RC1 lib/stitches/deprecation.rb
stitches-3.8.3 lib/stitches/deprecation.rb
stitches-3.8.2 lib/stitches/deprecation.rb
stitches-3.8.1 lib/stitches/deprecation.rb
stitches-3.8.0 lib/stitches/deprecation.rb
stitches-3.7.3 lib/stitches/deprecation.rb
stitches-3.7.2 lib/stitches/deprecation.rb