class RegisterableRedirect < OpenStruct
  include ActiveModel::Validations

  validates :type, inclusion: { in: %w(exact prefix), message: 'must be either "exact" or "prefix"' }
  validates :path, :destination, absolute_path: true
  validates :path, :type, :destination, presence: true

  def register!
    Rails.application.router_api.add_redirect_route(path, type, destination)
  end
end

class RegisterableRedirect < RegisterableRoute

  validates :destination, presence: true, absolute_path: true

  def register!
    Rails.application.router_api.add_redirect_route(path, type, destination)
  end
end

Refactor RegisterableRedirect to avoid duplication.
Refactor RegisterableRedirect to avoid duplication.

It shares all the validations of RegisterableRoute, so it makes sense
for it to inherit from it.
