Class: RedisMonitor::Controllers::BaseController

Inherits:
Object
  • Object
show all
Includes:
Helpers::BaseHelper, Helpers::LayoutsHelper
Defined in:
lib/controllers/base_controller.rb

Direct Known Subclasses

InfoController

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::LayoutsHelper

#main_layout

Methods included from Helpers::BaseHelper

#haml

Constructor Details

#initialize(opts = {}) ⇒ BaseController

Returns a new instance of BaseController.



12
13
14
15
# File 'lib/controllers/base_controller.rb', line 12

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

Instance Attribute Details

#contextObject

Returns the value of attribute context.



7
8
9
# File 'lib/controllers/base_controller.rb', line 7

def context
  @context
end

#paramsObject

Returns the value of attribute params.



7
8
9
# File 'lib/controllers/base_controller.rb', line 7

def params
  @params
end

Instance Method Details

#execute(action) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/controllers/base_controller.rb', line 17

def execute(action)
  begin
    send(action)
  rescue RedisMonitor::Errors::RedisNotAvailable
    redis_not_available
  end
end

#redis_not_availableObject



25
26
27
28
# File 'lib/controllers/base_controller.rb', line 25

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