class WebConsole::WhinyRequest - web-console-2.1.2 Documentation

# class WebConsole::WhinyRequest

Noisy wrapper around `Request`.

If any calls to `from_whitelisted_ip?` and `acceptable_content_type?` return false, an info log message will be displayed in users' logs.

### Public Instance Methods

acceptable_content_type?() click to toggle source

    # File lib/web_console/whiny_request.rb, line 14
    def acceptable_content_type?
      whine_unless request.acceptable_content_type? do
        "Cannot render console with content type #{request.content_type}"            "Allowed content types: #{request.acceptable_content_types}"
      end
    end

from_whitelited_ip?() click to toggle source

    # File lib/web_console/whiny_request.rb, line 7
    def from_whitelited_ip?
      whine_unless request.from_whitelited_ip? do
        "Cannot render console from #{request.remote_ip}! "            "Allowed networks: #{request.whitelisted_ips}"
      end
    end

### Private Instance Methods

logger() click to toggle source

    # File lib/web_console/whiny_request.rb, line 30
    def logger
      env['action_dispatch.logger'] || WebConsole.logger
    end

request() click to toggle source

    # File lib/web_console/whiny_request.rb, line 34
    def request
      __getobj__
    end

whine_unless(condition) { || ... } click to toggle source

    # File lib/web_console/whiny_request.rb, line 23
    def whine_unless(condition)
      unless condition
        logger.info { yield }
      end
      condition
    end