class StinkBomb::Configuration

Attributes

message[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/stink_bomb/configuration.rb, line 5
def initialize(options = {})
  self.message = options.fetch(:message) { default_message }
end

Public Instance Methods

bombs() click to toggle source
# File lib/stink_bomb/configuration.rb, line 17
def bombs
  @bombs ||= []
end
logger=(logger) click to toggle source
# File lib/stink_bomb/configuration.rb, line 13
def logger=(logger)
  configure_bomb(LoggerBomb, logger)
end
raise=(error_class) click to toggle source
# File lib/stink_bomb/configuration.rb, line 9
def raise=(error_class)
  configure_bomb(RaiseBomb, error_class)
end

Private Instance Methods

configure_bomb(bomb_type, bomb_arg) click to toggle source
# File lib/stink_bomb/configuration.rb, line 23
def configure_bomb(bomb_type, bomb_arg)
  remove_bomb(bomb_type)
  if bomb_arg == true
    bombs << bomb_type.new
  elsif bomb_arg
    bombs << bomb_type.new(bomb_arg)
  end
end
default_message() click to toggle source
# File lib/stink_bomb/configuration.rb, line 36
def default_message
  'Your code stinks! It was supposed to be fixed by {deadline}'
end
remove_bomb(bomb_class) click to toggle source
# File lib/stink_bomb/configuration.rb, line 32
def remove_bomb(bomb_class)
  bombs.delete_if { |bomb| bomb.is_a?(bomb_class) }
end