Sha256: 493eb61d4342035a2841bac6cb4d57fad95f94f671b0a0d0e13b4be4dfba4630

Contents?: true

Size: 754 Bytes

Versions: 11

Compression:

Stored size: 754 Bytes

Contents

# frozen_string_literal: true

module WebConsole
  # Noisy wrapper around +Request+.
  #
  # If any calls to +permitted?+ and +acceptable_content_type?+
  # return false, an info log message will be displayed in users' logs.
  class WhinyRequest < SimpleDelegator
    def permitted?
      whine_unless request.permitted? do
        "Cannot render console from #{request.strict_remote_ip}! " \
          "Allowed networks: #{request.permissions}"
      end
    end

    private

      def whine_unless(condition)
        unless condition
          logger.info { yield }
        end
        condition
      end

      def logger
        env["action_dispatch.logger"] || WebConsole.logger
      end

      def request
        __getobj__
      end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/web-console-4.2.1/lib/web_console/whiny_request.rb
web-console-4.2.1 lib/web_console/whiny_request.rb
web-console-4.2.0 lib/web_console/whiny_request.rb
web-console-4.1.0 lib/web_console/whiny_request.rb
web-console-4.0.4 lib/web_console/whiny_request.rb
web-console-4.0.3 lib/web_console/whiny_request.rb
web-console-4.0.2 lib/web_console/whiny_request.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/web-console-4.0.1/lib/web_console/whiny_request.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/web-console-4.0.1/lib/web_console/whiny_request.rb
web-console-4.0.1 lib/web_console/whiny_request.rb
web-console-4.0.0 lib/web_console/whiny_request.rb