Sha256: ae9b54eb25d07f9b62283f3389f377424f2157d164a856f9ae265f4ee70aa85e

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

class LinuxAdmin
  class RegistrationSystem < LinuxAdmin
    def self.registration_type(reload = false)
      return @registration_type if @registration_type && !reload
      @registration_type = registration_type_uncached
    end

    def self.method_missing(meth, *args, &block)
      if white_list_methods.include?(meth)
        r = self.registration_type.new
        raise NotImplementedError, "#{meth} not implemented for #{self.name}" unless r.respond_to?(meth)
        r.send(meth, *args, &block)
      else
        super
      end
    end

    def registered?
      false
    end

    private

    def self.registration_type_uncached
      if Rhn.new.registered?
        Rhn
      elsif SubscriptionManager.new.registered?
        SubscriptionManager
      else
        self
      end
    end
    private_class_method :registration_type_uncached

    def self.white_list_methods
      @white_list_methods ||= begin
        all_methods = RegistrationSystem.instance_methods(false) + Rhn.instance_methods(false) + SubscriptionManager.instance_methods(false)
        all_methods.uniq
      end
    end
    private_class_method :white_list_methods
  end
end

Dir.glob(File.join(File.dirname(__FILE__), "registration_system", "*.rb")).each { |f| require f }

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
linux_admin-0.5.1 lib/linux_admin/registration_system.rb
linux_admin-0.5.0 lib/linux_admin/registration_system.rb
linux_admin-0.4.1 lib/linux_admin/registration_system.rb