Sha256: 3a0ef5a3f00a551f8a1f13b8ba8c59adff07323165e99dfb39e3079caf08956a

Contents?: true

Size: 755 Bytes

Versions: 2

Compression:

Stored size: 755 Bytes

Contents

module MarkAsRead
  class MarkAsReadController < ActionController::Base

    def read
      verifier = ActiveSupport::MessageVerifier.new(Rails.application.config.secret_key_base)
      type = params[:type].constantize rescue nil
      raise UnknownType.new("No such type: #{type}") unless type
      raise InvalidType.new("Type #{type} is not a valid model type") unless type.respond_to?(:find)

      model = type.find(verifier.verify(params[:id]))
      raise InvalidType.new("Type #{type} does not include mark_as_read") unless model.respond_to?(:mark_as_read!)
      model.mark_as_read!
      send_data(Base64.decode64("R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="), :type => "image/gif", :disposition => "inline")
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mark_as_read-0.0.2 app/controllers/mark_as_read/mark_as_read_controller.rb
mark_as_read-0.0.1 app/controllers/mark_as_read/mark_as_read_controller.rb