Fix duplicate constant definitions for Ruby 1.8

Ruby 1.8.7 does not like the `||=` construction for Class constants,
so use `defined?` to check if the constants are already declared.

Fixes #169.
Merge pull request #170 from tmatilai/ruby-1.8-constants

Fix duplicate constant definitions for Ruby 1.8