有人可以帮助我了解alias_method在此代码中做什么

问题描述

我在理解这段代码中alias_method的目的时遇到了麻烦

ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
  alias_method :configure_connection_without_interval,:configure_connection
  define_method :configure_connection do
    configure_connection_without_interval
    execute('SET intervalstyle = iso_8601','SCHEMA')
  end
end

第4行调用configure_connection_without_interval的目的是什么-不仅仅是调用自身吗?

下面的代码对我有用,但是我不完全知道自己在做什么,我担心它以后会产生错误。

ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
  define_method :configure_connection do
    execute('SET intervalstyle = iso_8601','SCHEMA')
  end
end

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)