On Fri, Nov 9, 2012 at 3:27 PM, Erwin <[email protected]> wrote:

> When I have this pattern
>
>        sign_me(@user, :event => :authentication, :subdomain => subdomain)
>
> how can I write it to avoid sending the :subdomain option if
> subdomain.nil?   ( if possible ..)
>
>        sign_me(@user, :event => :authentication  #?, :subdomain =>
> subdomain unless subdomain.nil?  )
>

I'm not sure if it's possible to do it in a single line (as far as you want
to have a tidy code)

opts = { event: :authentication }
opts[:subdomain] = subdomain if subdomain

sign_me @user, opts



>
>  --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/TOTAudTTAa8J.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to