On Jan 28, 6:25 am, Ryan Angilly <angi...@gmail.com
> I also realized that I do crap like this a lot too:
> self.owner_object_association ? self.owner_object_association :
> Where this would give me:
> self.owner_object_association.or_if_blank? default_thing
I really don't like "or_if_blank?"
It feels like it should live in a gem,
partly because it doesn't seem necessary,
and partly because there are too many variants I could see people
But saying that,
A clear distinctinction needs to be made between;
>> a.blank? ? b : a
namely, in the first "b" only gets evaluated ONLY IF "a" is blank
in the second, "b" ALWAYS get evaluated.
It's not necessarily a problem.
But I worry that we'll see code like;
Perhaps a different approach would be something like this
(:full_name, :email, :something_else, :another_fallback)
which is equivalent to;
>> if user.full_name.present?
>> return user.full_name
>> elsif user.email.present?
>> return user.email
>> elsif user.something_else.present?
>> return user.something_else
>> elsif user.another_fallback.present?
>> return user.another_fallback
The bumblebee hovers around the user,
looking for a flower with some pollen.
It goes from flower to flower,
trying each method in order,
and when it finds one that isn't empty,
it returns it to the hive.