diff options
| author | mo khan <mo@mokhan.ca> | 2014-07-13 09:31:41 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-07-13 09:31:41 -0600 |
| commit | b820d323588765ed6b7f5022d1a7551cf304f51b (patch) | |
| tree | 6aac3213d4c3ecba10b783d82a0f5ff685776c06 /lib/humble/identity_map.rb | |
| parent | 9d11dbbb3053811be6fd54407e08b5119c9756b3 (diff) | |
move classes to separate files and startto build identity map.
Diffstat (limited to 'lib/humble/identity_map.rb')
| -rw-r--r-- | lib/humble/identity_map.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/humble/identity_map.rb b/lib/humble/identity_map.rb new file mode 100644 index 0000000..b19db43 --- /dev/null +++ b/lib/humble/identity_map.rb @@ -0,0 +1,14 @@ +class IdentityMap + def initialize(items = {}) + @items = items + end + + def fetch(key, &block) + if @items.key?(key) + @items[key] + else + @items[key] = block.call + @items[key] + end + end +end |
