跳至內容 跳至搜尋

Active Support – Rails 的工具類別和 Ruby 擴充功能

Active Support 是一組 Rails 框架中常用的工具類別和標準函式庫擴充功能。這些新增功能位於此套件中,以便在 Rails 之外的 Ruby 專案中視需要載入。

您可以在《Active Support 核心擴充功能》指南中閱讀更多關於擴充功能的資訊。

下載與安裝

最新版的 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