Wednesday, February 3, 2010, 8:53:49 PM, you wrote:
irb(main):012:0>> class Hash
irb(main):013:1>> alias_method
ld, :[]=
irb(main):014:1>> def []=(index, value)
irb(main):015:2>> p index
irb(main):016:2>> p value
irb(main):017:2>> old index, value
irb(main):018:2>> end
irb(main):019:1>> end
=>> nil
irb(main):020:0>> x={}
=>> {}
irb(main):021:0>> x[:foo]=:bar
WH> :foo
WH> :bar
=>> :bar
WH> That should get you where your trying to go.
WH> Best of luck!
So I tested this in irb and it seems to work fine ...
Then I stuck this into init.rb as part of a Rails app and ... boom ...
f:\Ralph-Rails-Apps\WebOfTrust>ruby script/server webrick --debugger
=> Booting WEBrick
=> Rails 2.3.5 application starting on
http://0.0.0.0:3000
F:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/validates_captcha-0.9.6/rail
s/init.rb:11:in `alias_method': undefined method `[]=' for class `Rails:
lugin:
:Hash' (NameError)
from F:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/validates_captc
ha-0.9.6/rails/init.rb:11:in `evaluate_init_rb'
from F:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib
/rails/plugin.rb:158:in `evaluate_init_rb'
from F:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2
3.5/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
from F:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib
/rails/plugin.rb:154:in `evaluate_init_rb'
from F:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib
/rails/plugin.rb:48:in `load'
from F:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib
/rails/plugin/loader.rb:38:in `load_plugins'
from F:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib
/rails/plugin/loader.rb:37:in `each'
from F:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib
/rails/plugin/loader.rb:37:in `load_plugins'
... 10 levels...
from F:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib
/commands/server.rb:84
from F:/InstantRails-2.0-win/ruby/lib/ruby/site_ruby/1.8/rubygems/custom
_require.rb:31:in `gem_original_require'
from F:/InstantRails-2.0-win/ruby/lib/ruby/site_ruby/1.8/rubygems/custom
_require.rb:31:in `require'
from script/server:3
I am so lost.
Rails has a plugin for Hash?!?!?!? And []= is undefined?!?!?