跳至内容 跳至搜索

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

Active Support 是在 Rails 框架中发现很有用的实用类和标准库扩展的集合。这些附加功能驻留在此包中,以便可以在 Rails 之外的 Ruby 项目中按需加载。

您可以在 Active Support Core Extensions 指南中阅读有关这些扩展的更多信息。

下载和安装

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

$ gem install activesupport

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

许可证

Active Support 在 MIT 许可证下发布

支持

API 文档位于:

Ruby on Rails 项目的错误报告可在此处提交:

功能请求应在此处的 rubyonrails-core 论坛上讨论:

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

类公共方法

cache_format_version()

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

cache_format_version=(value)

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

eager_load!()

# File activesupport/lib/active_support.rb, line 98
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 124
def self.to_time_preserves_timezone
  ActiveSupport.deprecator.warn(
    "`config.active_support.to_time_preserves_timezone` is deprecated and will be removed in Rails 8.2"
  )
  @to_time_preserves_timezone
end

to_time_preserves_timezone=(value)

# File activesupport/lib/active_support.rb, line 131
def self.to_time_preserves_timezone=(value)
  ActiveSupport.deprecator.warn(
    "`config.active_support.to_time_preserves_timezone` is deprecated and will be removed in Rails 8.2"
  )

  @to_time_preserves_timezone = value
end

utc_to_local_returns_utc_offset_times()

# File activesupport/lib/active_support.rb, line 139
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 143
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