def coerce(value, target_domain = main_target_domain)
      return value if belongs_to?(value, target_domain)
      error = nil
      each_rule do |from,to,converter|
        next unless from.nil? or belongs_to?(value, from, target_domain)
        begin
          catch(:nextrule) do
            if to.nil? or subdomain?(to, target_domain)
              got = convert(value, target_domain, converter)
              return got
            elsif subdomain?(target_domain, to)
              got = convert(value, target_domain, converter)
              return got if belongs_to?(got, target_domain)
            end
          end
        rescue => ex
          error = ex unless error
        end
      end
      error_handler.call(value, target_domain, error)
    end
def coerce(value, target_domain = main_target_domain)
      return value if belongs_to?(value, target_domain)
      error = nil
      each_rule do |from,to,converter|
        next unless from.nil? or belongs_to?(value, from, target_domain)
        begin
          catch(:nextrule) do
            if to.nil? or subdomain?(to, target_domain)
              got = convert(value, target_domain, converter)
              return got
            elsif subdomain?(target_domain, to)
              got = convert(value, target_domain, converter)
              return got if belongs_to?(got, target_domain)
            end
          end
        rescue => ex
          error = ex unless error
        end
      end
      error_handler.call(value, target_domain, error)
    end
Coerces `value` to an element of `target_domain`

 This method tries each coercion rule, then each fallback in turn. Rules
 for which source and target domain match are executed until one succeeds.
 A Myrrha::Error is raised if no rule matches or executes successfuly.

 @param [Object] value any ruby value
 @param [Domain] target_domain a target domain to convert to (mimic Domain)
 @return self