Skip to content

Commit

Permalink
Calling ActiveSupport::Deprecation.warn no longer allowed. Instantiat…
Browse files Browse the repository at this point in the history
…e and use module specific deprecator.
  • Loading branch information
varyonic committed Aug 13, 2024
1 parent 6a4dd7b commit 449c26e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/arbo.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'active_support/core_ext/string/output_safety'
require 'active_support/deprecation'
require 'active_support/hash_with_indifferent_access'
require 'active_support/inflector'

Expand All @@ -8,6 +7,7 @@ module Arbo

require 'arbo/element'
require 'arbo/context'
require 'arbo/deprecator'
require 'arbo/html/attributes'
require 'arbo/html/class_list'
require 'arbo/html/tag'
Expand Down
8 changes: 8 additions & 0 deletions lib/arbo/deprecator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'active_support/deprecation'

module Arbo
module_function
def deprecator # :nodoc:
@deprecator ||= ActiveSupport::Deprecation.new
end
end
6 changes: 3 additions & 3 deletions lib/arbo/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ def inspect
end

def to_str
ActiveSupport::Deprecation.warn("don't rely on implicit conversion of Element to String")
Arbo.deprecator.warn("don't rely on implicit conversion of Element to String")
content
end

def to_s
ActiveSupport::Deprecation.warn("#render_in should be defined for rendering #{method_owner(:to_s)} instead of #to_s")
Arbo.deprecator.warn("#render_in should be defined for rendering #{method_owner(:to_s)} instead of #to_s")
content
end

Expand All @@ -158,7 +158,7 @@ def render_in_or_to_s(context)
if method_distance(:render_in) <= method_distance(:to_s)
render_in(context)
else
ActiveSupport::Deprecation.warn("#render_in should be defined for rendering #{method_owner(:to_s)} instead of #to_s")
Arbo.deprecator.warn("#render_in should be defined for rendering #{method_owner(:to_s)} instead of #to_s")
to_s.tap { |s| context.output_buffer << s }
end
end
Expand Down

0 comments on commit 449c26e

Please sign in to comment.