class Stoplight::Light

Attributes

default_data_store[RW]

@return [DataStore::Base]

default_error_notifier[RW]

@return [Proc]

default_notifiers[RW]

@return [Array<Notifier::Base>]

code[R]

@return [Proc]

cool_off_time[R]

@return [Float]

data_store[R]

@return [DataStore::Base]

error_handler[R]

@return [Proc]

error_notifier[R]

@return [Proc]

fallback[R]

@return [Proc, nil]

name[R]

@return [String]

notifiers[R]

@return [Array<Notifier::Base>]

threshold[R]

@return [Fixnum]

Public Class Methods

new(name, &code) click to toggle source

@param name [String] @yield []

# File lib/stoplight/light.rb, line 41
def initialize(name, &code)
  @name = name
  @code = code

  @cool_off_time = Default::COOL_OFF_TIME
  @data_store = self.class.default_data_store
  @error_handler = Default::ERROR_HANDLER
  @error_notifier = self.class.default_error_notifier
  @fallback = Default::FALLBACK
  @notifiers = self.class.default_notifiers
  @threshold = Default::THRESHOLD
end

Public Instance Methods

with_cool_off_time(cool_off_time) click to toggle source

@param cool_off_time [Float] @return [self]

# File lib/stoplight/light.rb, line 56
def with_cool_off_time(cool_off_time)
  @cool_off_time = cool_off_time
  self
end
with_data_store(data_store) click to toggle source

@param data_store [DataStore::Base] @return [self]

# File lib/stoplight/light.rb, line 63
def with_data_store(data_store)
  @data_store = data_store
  self
end
with_error_handler(&error_handler) click to toggle source

@yieldparam error [Exception] @yieldparam handle [Proc] @return [self]

# File lib/stoplight/light.rb, line 71
def with_error_handler(&error_handler)
  @error_handler = error_handler
  self
end
with_error_notifier(&error_notifier) click to toggle source

@yieldparam error [Exception] @return [self]

# File lib/stoplight/light.rb, line 78
def with_error_notifier(&error_notifier)
  @error_notifier = error_notifier
  self
end
with_fallback(&fallback) click to toggle source

@yieldparam error [Exception, nil] @return [self]

# File lib/stoplight/light.rb, line 85
def with_fallback(&fallback)
  @fallback = fallback
  self
end
with_notifiers(notifiers) click to toggle source

@param notifiers [Array<Notifier::Base>] @return [self]

# File lib/stoplight/light.rb, line 92
def with_notifiers(notifiers)
  @notifiers = notifiers
  self
end
with_threshold(threshold) click to toggle source

@param threshold [Fixnum] @return [self]

# File lib/stoplight/light.rb, line 99
def with_threshold(threshold)
  @threshold = threshold
  self
end