stefan-kolb/nucleus

View on GitHub
lib/nucleus_api/persistence/daos/endpoint_dao.rb

Summary

Maintainability
A
45 mins
Test Coverage
module Nucleus
  module API
    module DB
      module EndpointDao
        def self.instance(api_version)
          key = "@@__instance__#{api_version}".to_sym
          return class_variable_get(key) if class_variable_defined?(key)
          class_variable_set(key, VersionDependantEndpointDao.new(api_version))
        end
      end

      class VersionDependantEndpointDao < Nucleus::DB::Store
        include Nucleus::Logging

        def initialize(api_version)
          log.debug "Creating new VersionDependantEndpointDao for version #{api_version}"
          super(api_version, 'endpoints')
        end
      end
    end
  end
end