Sha256: 34cf9537d0ff8845192273eaafbb7733609db92dd1568ec8ca99b75661d5789a

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

require 'modules/backend'
require 'errors/errors'

module RedisMonitor
  module Controllers
    class BaseController
      attr_accessor :context, :params

      include RedisMonitor::Helpers::BaseHelper
      include RedisMonitor::Helpers::LayoutsHelper

      def initialize(opts = {})
        @context = opts.delete(:context)
        @params = opts
      end

      def execute(action, params = {})
        begin
          send(action, params)
        rescue RedisMonitor::Errors::RedisNotAvailable
          redis_not_available
        end
      end

      def redis_not_available
        haml 'errors/redis_not_available'.to_sym, layout: main_layout,
                     locals: {host: Backend.host, port: Backend.port}
      end

      def http_referer
        context.env['HTTP_REFERER']
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redis_monitor-0.0.6 lib/controllers/base_controller.rb