Permalink
Browse files

Providing full access to a resource's meta-data using good ol' hash r…

…eference

semantics. Enjoy!

(I can't figure out if the chickens are really smart or really stupid.
I usually lean towards the latter, but then they outsmart the two year old.)
  • Loading branch information...
1 parent 62c811c commit 275adf3494b455b21c34c65ab305987960ebe5bd @TwP TwP committed Jun 11, 2008
Showing with 12 additions and 2 deletions.
  1. +12 −2 lib/webby/resources/resource.rb
@@ -72,10 +72,20 @@ def <=>( other )
# resource[key] => value or nil
#
# Returns the value associated with the given meta-data key. Key is
- # usually a string.
+ # converted into a string.
#
def []( key )
- @mdata[key]
+ @mdata[key.to_s]
+ end
+
+ # call-seq:
+ # resource[key] = value
+ #
+ # Sets the given meta-data key to the value. Key is converted into a
+ # string.
+ #
+ def []=( key, value )
+ @mdata[key.to_s] = value
end
# call-seq:

0 comments on commit 275adf3

Please sign in to comment.