跳到內容 跳到搜尋

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 104
def self.cache_format_version
  Cache.format_version
end

cache_format_version=(value)

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

eager_load!()

# File activesupport/lib/active_support.rb, line 92
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 112
def self.to_time_preserves_timezone
  DateAndTime::Compatibility.preserve_timezone
end

to_time_preserves_timezone=(value)

# File activesupport/lib/active_support.rb, line 116
def self.to_time_preserves_timezone=(value)
  unless value
    ActiveSupport.deprecator.warn(
      "Support for the pre-Ruby 2.4 behavior of to_time has been deprecated and will be removed in Rails 7.2."
    )
  end

  DateAndTime::Compatibility.preserve_timezone = value
end

utc_to_local_returns_utc_offset_times()

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