RUBY-698 separate flag logic in serialization for each regexp type