跳至内容 跳至搜索

Active Support – Rails 的实用程序类和 Ruby 扩展

Active Support 是一个实用程序类和标准库扩展的集合,它们被发现对 Rails 框架很有用。这些扩展存在于此包中,以便它们可以按需加载到 Rails 之外的 Ruby 项目中。

您可以在 Active Support Core Extensions 指南中了解更多关于扩展的信息。

下载和安装

Active Support 的最新版本可以使用 RubyGems 安装

$ gem install activesupport

源代码可以作为 GitHub 上 Rails 项目的一部分下载

许可证

Active Support 在 MIT 许可证下发布

支持

API 文档位于

Ruby on Rails 项目的错误报告可以在这里提交

功能请求应在 rails-core 邮件列表中讨论,地址如下

命名空间
方法
C
E
G
T
U
V

类公有方法

cache_format_version()

# File activesupport/lib/active_support.rb, line 106
def self.cache_format_version
  Cache.format_version
end

cache_format_version=(value)

# File activesupport/lib/active_support.rb, line 110
def self.cache_format_version=(value)
  Cache.format_version = value
end

eager_load!()

# File activesupport/lib/active_support.rb, line 94
def self.eager_load!
  super

  NumberHelper.eager_load!
end

gem_version()

返回当前加载的 Active Support 版本,以 Gem::Version 格式。

# File activesupport/lib/active_support/gem_version.rb, line 5
def self.gem_version
  Gem::Version.new VERSION::STRING
end

to_time_preserves_timezone()

# File activesupport/lib/active_support.rb, line 114
def self.to_time_preserves_timezone
  DateAndTime::Compatibility.preserve_timezone
end

to_time_preserves_timezone=(value)

# File activesupport/lib/active_support.rb, line 118
def self.to_time_preserves_timezone=(value)
  if !value
    ActiveSupport.deprecator.warn(
      "`to_time` will always preserve the receiver timezone rather than system local time in Rails 8.1. " \
      "To opt in to the new behavior, set `config.active_support.to_time_preserves_timezone = :zone`."
    )
  elsif value != :zone
    ActiveSupport.deprecator.warn(
      "`to_time` will always preserve the full timezone rather than offset of the receiver in Rails 8.1. " \
      "To opt in to the new behavior, set `config.active_support.to_time_preserves_timezone = :zone`."
    )
  end

  DateAndTime::Compatibility.preserve_timezone = value
end

utc_to_local_returns_utc_offset_times()

# File activesupport/lib/active_support.rb, line 134
def self.utc_to_local_returns_utc_offset_times
  DateAndTime::Compatibility.utc_to_local_returns_utc_offset_times
end

utc_to_local_returns_utc_offset_times=(value)

# File activesupport/lib/active_support.rb, line 138
def self.utc_to_local_returns_utc_offset_times=(value)
  DateAndTime::Compatibility.utc_to_local_returns_utc_offset_times = value
end

version()

返回当前加载的 Active Support 版本,以 Gem::Version 格式。

# File activesupport/lib/active_support/version.rb, line 7
def self.version
  gem_version
end