Can I put some form of If..End blocks inside of a hash definition?
- by Benjamin Manns
I am creating a web application to integrate with Chargify. I want to return a hash with customer_id set if the user has a customer associated with the account, and customer_attributes if a customer has to be created.
Is there any way that I could do this with an if..end block inside of the hash definition. For example, I would be wanting to do something like the following (does not work):
def subscription_params(product_id)
{
:product_id => product_id,
if customer_id.nil?
:customer_attributes => customer_params,
else
:customer_id => customer_id,
end
:credit_card_attributes => credit_card_params
}
end