Forum: Ruby Re: Hash#getopt

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Berger, Daniel (Guest)
on 2006-04-26 17:51
(Received via mailing list)
> >
> > h.ignore_key_case = true # or whatever
> globally for hashes requires a good bit of code to make
>
>
> by sticking to access of options only it's possible to
> provide an easy way to do the normal thing in 98% of cases.
> as the above two examples show though, a more general
> approach involves making lots of choices about string/symbol
> interaction.  i actually do this in my own code but it's
> slippery and not for general consumption.

I thought AOP might be appropriate here, but I couldn't make it work:

require 'aspectr'
include AspectR

class SymAspect < Aspect
   def pre(method, object, exit_status, *args)
      puts "In the pre method"
      args.map!{ |arg| arg.to_s.downcase }
   end
end

SymAspect.new.wrap(Hash, :pre, nil, :[])
h = {'foo', 1, 'bar', 2}
h['foo'] # nothing - why?

(I posted a similar question on c.l.r. via Google G., btw)

Regardless of whether or not this is a bug, what do you think of AOP
as an approach to this issue?

Regards,

Dan


This communication is the property of Qwest and may contain confidential
or
privileged information. Unauthorized use of this communication is
strictly
prohibited and may be unlawful.  If you have received this communication
in error, please immediately notify the sender by reply e-mail and
destroy
all copies of the communication and any attachments.
This topic is locked and can not be replied to.