class Evertils::Controller::Base

Constants

OK

Exit code to indicate everything is ok!

QUIT

Exit code to indicate a force quit (exit) call, meaning the program quit with an error

QUIT_SOFT

Exit code to indicate that the program exited with a non-zero exit code, but not one that resulted in a force quit

Attributes

config[RW]

Access the configuration object instance externally

request[RW]

Access the request object instance externally

Public Class Methods

new(config, request) click to toggle source

Setup internal variables that will be used in subclasses Params:

config

Instance of Evertils::Cfg to enable access to config file

request

Instance of Evertils::Request, enables access to request parameters

# File lib/evertils/controller.rb, line 25
def initialize(config, request)
  @config = config
  @request = request
end

Public Instance Methods

can_exec?(command, config) click to toggle source

Determines if the command can execute Params:

command

Symbol containing the command we want to execute

config

Configuration data

# File lib/evertils/controller.rb, line 51
def can_exec?(command, config)
  # no command was passed, check if controller has a default method
  if command.nil? && respond_to?(:default)
    @method = :default
  elsif respond_to? command
    # check the controller for the requested method
    @method = command
  elsif is_a? Evertils::Controller::Render
    @method = :from_file
  else
    raise NoMethodError, "Invalid method: #{command}"
  end
end
exec() click to toggle source

Handle the request

# File lib/evertils/controller.rb, line 35
def exec
  if @request.param.nil?
    send(@method.to_sym)
  else
    send(@method.to_sym, (@request.flags.first || @request.param))
  end
end
post_exec() click to toggle source

Perform post-run cleanup tasks, such as deleting old logs

# File lib/evertils/controller.rb, line 44
def post_exec
end
pre_exec() click to toggle source

Perform pre-run tasks

# File lib/evertils/controller.rb, line 31
def pre_exec
end
sample() click to toggle source

Default method called by exec if no argument is passed

# File lib/evertils/controller.rb, line 66
def sample
  Notify.warning("Method not implemented")
end