Sha256: 11f74c936365b08cb250725df0a52c44099c1e49027e4fc63d16a2ba7b1ea840

Contents?: true

Size: 379 Bytes

Versions: 5

Compression:

Stored size: 379 Bytes

Contents

module EY
  class CloudClient
    class ModelRegistry
      def initialize
        @registry = Hash.new { |h,k| h[k] = {} }
      end

      def find(klass, id)
        if id
          @registry[klass][id]
        end
      end

      def set(klass, obj)
        if obj.respond_to?(:id) && id = obj.id
          @registry[klass][id] = obj
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
engineyard-cloud-client-1.0.2 lib/engineyard-cloud-client/model_registry.rb
engineyard-cloud-client-1.0.1 lib/engineyard-cloud-client/model_registry.rb
engineyard-cloud-client-1.0.0 lib/engineyard-cloud-client/model_registry.rb
engineyard-cloud-client-0.1.4 lib/engineyard-cloud-client/model_registry.rb
engineyard-cloud-client-0.1.2 lib/engineyard-cloud-client/model_registry.rb