class SmsValidation::Configuration

Constants

LOG_LEVEL_OPTIONS
ON_MESSAGE_TOO_LONG_OPTIONS

Attributes

log_level[R]
logger[R]
on_message_too_long[R]

Public Class Methods

new() click to toggle source
# File lib/sms_validation/configuration.rb, line 17
def initialize
  @logger = Rails.logger if defined?(::Rails.logger)
  @log_level = :debug
  @on_message_too_long = :raise_error
end

Public Instance Methods

log_at(level) click to toggle source
# File lib/sms_validation/configuration.rb, line 28
def log_at(level)
  validate_logger(@logger, level)
  @log_level = level
end
logger=(_logger) click to toggle source
# File lib/sms_validation/configuration.rb, line 33
def logger=(_logger)
  validate_logger(_logger, @log_level)
  @logger = _logger
end
on_message_too_long=(action) click to toggle source
# File lib/sms_validation/configuration.rb, line 23
def on_message_too_long=(action)
  raise ArgumentError, "SmsValidation.configuration.on_message_too_long must be included in: #{options_string(ON_MESSAGE_TOO_LONG_OPTIONS)}.  It cannot be \"#{action}\"" unless ON_MESSAGE_TOO_LONG_OPTIONS.include?(action)
  @on_message_too_long = action
end

Private Instance Methods

options_string(array) click to toggle source
# File lib/sms_validation/configuration.rb, line 44
def options_string(array)
  "[:#{array.join(", :")}]"
end
validate_logger(_logger, level) click to toggle source
# File lib/sms_validation/configuration.rb, line 39
def validate_logger(_logger, level)
  raise ArgumentError, "SmsValidation.configuration.log_at argument must be included in: #{options_string(LOG_LEVEL_OPTIONS)}.  It cannot be \"#{level}\"" unless LOG_LEVEL_OPTIONS.include?(level)
  raise ArgumentError, "SmsValidation.configuration.logger must respond to \"#{level}\"" if _logger && !_logger.respond_to?(level)
end