def uniqable(*fields, to_param: nil)
      fields = [:uid] if fields.blank?
      fields.each do |name|
        before_create { |record| record.uniqable_uid(name) }
      end
      define_singleton_method :uniqable_fields do
        fields
      end

      return if to_param.blank? # :to_param option
      define_method :to_param do
        public_send(to_param)
      end
    end
def uniqable(*fields, to_param: nil)
      fields = [:uid] if fields.blank?
      fields.each do |name|
        before_create { |record| record.uniqable_uid(name) }
      end
      define_singleton_method :uniqable_fields do
        fields
      end

      return if to_param.blank? # :to_param option
      define_method :to_param do
        public_send(to_param)
      end
    end
Uniqable fields and options declaration
 @example:
   uniqable :uid, :slug, to_param: :uid
 rubocop:disable Metrics/MethodLength