Class: ExceptionHandler::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/exception_handler/config.rb

Constant Summary collapse

TABLE_NAME =

Default Table Name Has to be “errors” because “exceptions” is a reserved word

:errors
DEFAULTS =
{
  dev:    false, #-> defaults to "false" for dev mode
  db:     false, #-> defaults to :errors if true, else use "table_name" / :table_name
  email: 	false, #-> requires string email and ActionMailer
  social: {
    facebook: { name: "frontline.utilities", url: "https://facebook.com" },
    twitter:  { name: "frontlineutils",      url: "http://twitter.com" },
    youtube:  { name: "frontlineutils",      url: "https://youtube.com/user" },
    linkedin: { name: "frontline-utilities", url: "https://linkedin.com/company" },
    fusion:   { name: "flutils",             url: "https://frontlinefusion.com" }
  },
  layouts: {
    "400" => nil, # => inherits from "ApplicationController" layout
    "500" => "exception"
  },
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values = nil) ⇒ Config

Init

Raises:

  • (Exception)


18
19
20
21
22
23
24
25
26
27
# File 'lib/exception_handler/config.rb', line 18

def initialize values=nil
  defaults = values.present? ? Config::DEFAULTS.deep_merge!(values) : DEFAULTS
  defaults.each do |k,v|
    instance_variable_set("@#{k}",v) #-> http://apidock.com/ruby/Object/instance_variable_set
  end

  # => Errors
  raise(Exception, "ExceptionHandler :: Valid Email Required") if @email && !@email.is_a?(String)
  #raise(Exception, "ExceptionHandler :: Migration Required → Table \"#{db}\" doesn't exist") if @db && !ActiveRecord::Base.connection.table_exists?(db)
end

Instance Attribute Details

#dbObject

DB



13
14
15
# File 'lib/exception_handler/config.rb', line 13

def db
  @db
end

#devObject

Instace Objects



13
14
15
# File 'lib/exception_handler/config.rb', line 13

def dev
  @dev
end

#emailObject

Instace Objects



13
14
15
# File 'lib/exception_handler/config.rb', line 13

def email
  @email
end

#layoutsObject

Instace Objects



13
14
15
# File 'lib/exception_handler/config.rb', line 13

def layouts
  @layouts
end

#socialObject

Instace Objects



13
14
15
# File 'lib/exception_handler/config.rb', line 13

def social
  @social
end