module FSSM::Backends

Public Class Methods

const_missing(symbol) click to toggle source
Calls superclass method
# File lib/fssm.rb, line 53
def const_missing(symbol)
  symbol == :Default ? set_backend(symbol, FSSM::Support.backend) : super
end
set_backend(const_symbol=nil, value=nil) click to toggle source
# File lib/fssm.rb, line 32
def set_backend(const_symbol=nil, value=nil)
  const_symbol ||= :Default
  value ||= ::FSSM::Support.backend
  
  if (value.is_a?(Symbol) || value.is_a?(String))
    unless const_defined?(value)
      raise NameError,
        "uninitialized constant FSSM::Backends::#{value}"
    end
    value = const_get(value)
  end
  
  unless value.is_a?(Class)
    raise ArgumentError,
      "value must be a class or the symbol of an existing backend"
  end
  
  remove_const(const_symbol) if const_defined?(const_symbol)
  const_set(const_symbol, value)
end