class Leeroy::State

Public Class Methods

new(*args, &block) click to toggle source
Calls superclass method Leeroy::Helpers::Polling::new
# File lib/leeroy/state.rb, line 60
def initialize(*args, &block)
  super

  self.dump_properties = [
    :data,
    :metadata,
  ]
end

Public Instance Methods

fetch(*args, &block) click to toggle source
# File lib/leeroy/state.rb, line 19
def fetch(*args, &block)
  begin
    self.data.send(:fetch, *args, &block)

  rescue KeyError => e
    logger.debug e.message

    not_found = args[0]
    logger.debug "property '#{not_found}' not found in statedata, checking state"

    begin
      self.send(not_found.to_sym, &block)

    rescue KeyError => e
      logger.debug e.message

      logger.warn "property '#{not_found}' not found in statedata or state"
    end

  rescue StandardError => e
    raise e
  end
end
method_missing(method, *args, &block) click to toggle source
# File lib/leeroy/state.rb, line 43
def method_missing(method, *args, &block)
  begin
    self.data.send(method.to_sym, *args, &block)

  rescue NoMethodError => e
    logger.debug e.message
    if self.respond_to?(method.to_sym)
      self.send(method.to_sym, *args, &block)
    else
      raise e
    end

  rescue StandardError => e
    raise e
  end
end