From: Tom Sawyer Date: 2003-01-07T20:51:58+09:00 Subject: Re: attr_cast, one a small step for interface techniques On Tuesday 07 January 2003 01:14 am, Mauricio Fern�ndez wrote: > > def attr_reader(*args) > > if args.last.kind_of?(Hash) or args.last.kind_of?(Array) > > attr_reader_with_cast(args.pop) > > end > > attr_reader_basic(*args) > > end > > > > def attr_reader_with_cast(harg) > > harg.each { |name, cast| > > What happens when harg is an Array? perhaps that should be removed. i had thought one could do this: attr_accessor [ [:avar, :to_s], ...] but that's rather pointless isn't it? i had only thought of allowing it b/c the same code works with it as does for Hash, i.e. harg.each { |name, cast| ... } -- tom sawyer, aka transami transami@transami.net .''. .''. . *''* :_\/_: . :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'. .''.: /\ : ./)\ ':'* /\ * : '..'. -=:o:=- :_\/_:'.:::. | ' *''* * '.\'/.' _\(/_'.':'.' : /\ : ::::: = *_\/_* -= o =- /)\ ' * '..' ':::' === * /\ * .'/.\'. '._____ * | *..* : |. |' .---"| * | _ .--'| || | _| | * | .-'| __ | | | || | .-----. | |' | || | | | | | || | ___' ' /"\ | '-."". '-' '-.' '` |_. ------------------------------------------------------------