Unless I am mistaken, I'm afraid there is no other way.
On Trusty, the resource Package['ruby'] will be defined to install ruby itself.

If we don't check if the resource Package['ruby'] is already defined, puppet will attempt to declare a second Package['ruby'] resource since that is the package that installs ruby gems - thus, resulting in a duplicate resource error, preventing the catalog from compiling. 'rubygems' is aliased to 'ruby' since we're assining 'ruby' as the name for the rubygems package.

The change above is made to fix trusty while maintaining backwards compatibility.