一個受管理的 deprecator 集合。設定方法,例如 behavior=
,會影響集合中的所有 deprecator。此外,silence
方法會在指定區塊的執行期間讓集合中的所有 deprecator 保持靜默。
方法
- #
- B
- D
- E
- N
- S
類別公開方法
new() 連結
程式碼:顯示 | 在 GitHub 上
# File activesupport/lib/active_support/deprecation/deprecators.rb, line 10 def initialize @options = {} @deprecators = {} end
實例公開方法
[](name) 連結
傳回透過 []=
加入此集合的 deprecator。
程式碼:顯示 | 在 GitHub 上
# File activesupport/lib/active_support/deprecation/deprecators.rb, line 16 def [](name) @deprecators[name] end
[]=(name, deprecator) 連結
將指定的 deprecator
加入此集合。該 deprecator 將立即使用先前在此集合上設定的任何選項進行設定。
deprecators = ActiveSupport::Deprecation::Deprecators.new
deprecators.debug = true
foo_deprecator = ActiveSupport::Deprecation.new("2.0", "Foo")
foo_deprecator.debug # => false
deprecators[:foo] = foo_deprecator
deprecators[:foo].debug # => true
foo_deprecator.debug # => true
程式碼:顯示 | 在 GitHub 上
# File activesupport/lib/active_support/deprecation/deprecators.rb, line 34 def []=(name, deprecator) apply_options(deprecator) @deprecators[name] = deprecator end
behavior=(behavior) 連結
設定此集合中所有 deprecator 的過時警告行為。
程式碼:顯示 | 在 GitHub 上
# File activesupport/lib/active_support/deprecation/deprecators.rb, line 60 def behavior=(behavior) set_option(:behavior, behavior) end
debug=(debug) 連結
設定此集合中所有 deprecator 的除錯旗標。
程式碼:顯示 | 在 GitHub 上
# File activesupport/lib/active_support/deprecation/deprecators.rb, line 52 def debug=(debug) set_option(:debug, debug) end
disallowed_behavior=(disallowed_behavior) 連結
設定此集合中所有 deprecator 的不允許過時警告行為。
程式碼:顯示 | 在 GitHub 上
# File activesupport/lib/active_support/deprecation/deprecators.rb, line 68 def disallowed_behavior=(disallowed_behavior) set_option(:disallowed_behavior, disallowed_behavior) end
disallowed_warnings=(disallowed_warnings) 連結
設定此集合中所有 deprecator 的不允許過時警告。
程式碼:顯示 | 在 GitHub 上
# File activesupport/lib/active_support/deprecation/deprecators.rb, line 76 def disallowed_warnings=(disallowed_warnings) set_option(:disallowed_warnings, disallowed_warnings) end
each(&block) 連結
迭代此集合中的所有 deprecator。如果未提供區塊,則傳回 Enumerator
。
程式碼:顯示 | 在 GitHub 上
# File activesupport/lib/active_support/deprecation/deprecators.rb, line 41 def each(&block) return to_enum(__method__) unless block @deprecators.each_value(&block) end
silence(&block) 連結
在指定區塊的執行期間,讓此集合中的所有 deprecator 保持靜默。
程式碼:顯示 | 在 GitHub 上
# File activesupport/lib/active_support/deprecation/deprecators.rb, line 84 def silence(&block) each { |deprecator| deprecator.begin_silence } block.call ensure each { |deprecator| deprecator.end_silence } end
silenced=(silenced) 連結
設定此集合中所有 deprecator 的靜默旗標。
程式碼:顯示 | 在 GitHub 上
# File activesupport/lib/active_support/deprecation/deprecators.rb, line 47 def silenced=(silenced) set_option(:silenced, silenced) end