From 98e208c8744d2aa3bce4e74246d07bb64d044c91 Mon Sep 17 00:00:00 2001 From: Gibheer Date: Wed, 22 Jun 2011 07:46:28 +0200 Subject: [PATCH] added [] and []= als aliases for find and add --- lib/polecat/storage/binary_storage.rb | 2 ++ lib/polecat/storage/hash_storage.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/polecat/storage/binary_storage.rb b/lib/polecat/storage/binary_storage.rb index aaa8446..5109328 100644 --- a/lib/polecat/storage/binary_storage.rb +++ b/lib/polecat/storage/binary_storage.rb @@ -36,6 +36,7 @@ module Polecat end # end of while end end + alias :[]= :add def delete key check_key key @@ -96,6 +97,7 @@ module Polecat end nil end + alias :[] :find def select node = @root, &block if node.nil? diff --git a/lib/polecat/storage/hash_storage.rb b/lib/polecat/storage/hash_storage.rb index 4f1e433..305de72 100644 --- a/lib/polecat/storage/hash_storage.rb +++ b/lib/polecat/storage/hash_storage.rb @@ -10,6 +10,7 @@ module Polecat check_key key @storage[key] = value end + alias :[]= :add def delete key check_key key @@ -32,6 +33,7 @@ module Polecat nil end end + alias :[] :find def select &block out = []