Sha256: ed0f69596fdcbc29e5fe1afd7baf0493e21da9e7c2ec58212c210279313db563
Contents?: true
Size: 602 Bytes
Versions: 2
Compression:
Stored size: 602 Bytes
Contents
# encoding: UTF-8 module Goldiloader class ModelRegistry def initialize @registry = {} end def register(record, association_path) key = registry_key(record, association_path) @registry[key] ||= [] @registry[key] << record end # Returns all models with the same base class loaded from the same association path def peers(record, association_path) @registry.fetch(registry_key(record, association_path), []) end private def registry_key(record, association_path) [record.class.base_class, association_path] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
goldiloader-0.0.4 | lib/goldiloader/model_registry.rb |
goldiloader-0.0.3 | lib/goldiloader/model_registry.rb |