Class: ExceptionHandler::Config
- Inherits:
-
Object
- Object
- ExceptionHandler::Config
- Defined in:
- lib/exception_handler/config.rb
Constant Summary collapse
- TABLE =
> Table Name
> Has to be “errors” because “exceptions” is a reserved word
:errors- SOCIAL =
> Social URLs
> Extracted from “social” block
{ facebook: "https://facebook.com", twitter: "https://twitter.com", youtube: "https://youtube.com/user", linkedin: "https://linkedin.com/company", fusion: "https://frontlinefusion.com" }
- DEFAULTS =
> Defaults
> stackoverflow.com/a/8917301/1143732
{ dev: nil, # => defaults to "false" for dev mode db: nil, # => defaults to :errors if true, else use "table_name" / :table_name email: nil, # => requires string email and ActionMailer social: { facebook: nil, twitter: nil, youtube: nil, linkedin: nil, fusion: nil, }, layouts: { # => nil inherits from ApplicationController # => 4xx errors should be nil # => 5xx errors should be "exception" but can be nil if explicitly defined 500 => "exception", 501 => "exception", 502 => "exception", 503 => "exception", 504 => "exception", 505 => "exception", 507 => "exception", 510 => "exception" } }
Instance Attribute Summary collapse
-
#custom_exceptions ⇒ Object
> Instace Objects => ExceptionHandler.config.dev => ExceptionHandler.config.db => ExceptionHandler.config.email => ExceptionHandler.config.social => ExceptionHandler.config.layouts => ExceptionHandler.config.custom_exceptions.
-
#db ⇒ Object
> DB => If config db = “true”, use TABLE constant.
-
#dev ⇒ Object
> Instace Objects => ExceptionHandler.config.dev => ExceptionHandler.config.db => ExceptionHandler.config.email => ExceptionHandler.config.social => ExceptionHandler.config.layouts => ExceptionHandler.config.custom_exceptions.
-
#email ⇒ Object
> Instace Objects => ExceptionHandler.config.dev => ExceptionHandler.config.db => ExceptionHandler.config.email => ExceptionHandler.config.social => ExceptionHandler.config.layouts => ExceptionHandler.config.custom_exceptions.
-
#layouts ⇒ Object
> Instace Objects => ExceptionHandler.config.dev => ExceptionHandler.config.db => ExceptionHandler.config.email => ExceptionHandler.config.social => ExceptionHandler.config.layouts => ExceptionHandler.config.custom_exceptions.
-
#social ⇒ Object
> Instace Objects => ExceptionHandler.config.dev => ExceptionHandler.config.db => ExceptionHandler.config.email => ExceptionHandler.config.social => ExceptionHandler.config.layouts => ExceptionHandler.config.custom_exceptions.
Instance Method Summary collapse
-
#initialize(values) ⇒ Config
constructor
> Init => Merges DEFAULTS to values, creates instances vars (for attr_accessor).
Constructor Details
#initialize(values) ⇒ Config
> Init
> Merges DEFAULTS to values, creates instances vars (for attr_accessor)
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/exception_handler/config.rb', line 76 def initialize values # => Vars DEFAULTS.deep_merge!(values || {}).each do |k,v| instance_variable_set("@#{k}",v) end # => Validation raise ExceptionHandler::Error, "Email Not Valid" if @email && !@email.nil? && !@email.is_a?(String) raise ExceptionHandler::Error, "Migration Required → \"#{db}\" doesn't exist" if @db && !ActiveRecord::Base.connection.table_exists?(db) end |
Instance Attribute Details
#custom_exceptions ⇒ Object
> Instace Objects
> ExceptionHandler.config.dev
> ExceptionHandler.config.db
> ExceptionHandler.config.email
> ExceptionHandler.config.social
> ExceptionHandler.config.layouts
> ExceptionHandler.config.custom_exceptions
19 20 21 |
# File 'lib/exception_handler/config.rb', line 19 def custom_exceptions @custom_exceptions end |
#db ⇒ Object
> DB
> If config db = “true”, use TABLE constant
19 20 21 |
# File 'lib/exception_handler/config.rb', line 19 def db @db end |
#dev ⇒ Object
> Instace Objects
> ExceptionHandler.config.dev
> ExceptionHandler.config.db
> ExceptionHandler.config.email
> ExceptionHandler.config.social
> ExceptionHandler.config.layouts
> ExceptionHandler.config.custom_exceptions
19 20 21 |
# File 'lib/exception_handler/config.rb', line 19 def dev @dev end |
#email ⇒ Object
> Instace Objects
> ExceptionHandler.config.dev
> ExceptionHandler.config.db
> ExceptionHandler.config.email
> ExceptionHandler.config.social
> ExceptionHandler.config.layouts
> ExceptionHandler.config.custom_exceptions
19 20 21 |
# File 'lib/exception_handler/config.rb', line 19 def email @email end |
#layouts ⇒ Object
> Instace Objects
> ExceptionHandler.config.dev
> ExceptionHandler.config.db
> ExceptionHandler.config.email
> ExceptionHandler.config.social
> ExceptionHandler.config.layouts
> ExceptionHandler.config.custom_exceptions
19 20 21 |
# File 'lib/exception_handler/config.rb', line 19 def layouts @layouts end |
#social ⇒ Object
> Instace Objects
> ExceptionHandler.config.dev
> ExceptionHandler.config.db
> ExceptionHandler.config.email
> ExceptionHandler.config.social
> ExceptionHandler.config.layouts
> ExceptionHandler.config.custom_exceptions
19 20 21 |
# File 'lib/exception_handler/config.rb', line 19 def end |