------art_55982_23926786.1230052642451
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Tue, Dec 23, 2008 at 11:57 AM, James Coglan <jcoglan / googlemail.com>wrote:

> >
> >  # Return a hash of the navigation parameters
> >  def nav_params
> >    params  }
> >
> >    params[:prefix]       prefix      if @prefix
> >    params[:category_id]  category_id if @category_id
> >    params[:page]         page        if @page
> >
> >    params
> >  end
> >
> > I want to load a parameters hash with the contents of some instance
> > variables, but only if they are defined.
>
>
>
> params  :prefix, :category_id, :page].inject({}) do |hash, name|
>  var  nstance_variable_get("@#{name}")
>  hash[name]  ar if var
>  hash
> end
>
Thanks... that's certainly along the lines of what I was searching for.
I'll go read about #instance_variable_get now.

--wpd

------art_55982_23926786.1230052642451--