Skip to content

Commit

Permalink
made deprecation activesupport 7.2 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
klobuczek committed Sep 23, 2024
1 parent 4fca7c6 commit 523a07e
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 11 deletions.
3 changes: 3 additions & 0 deletions lib/active_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
loader.ignore(File.expand_path('active_graph/railtie.rb', __dir__))
loader.inflector.inflect("ansi" => "ANSI")
module ActiveGraph
def self.deprecator
@deprecator ||= ActiveSupport::Deprecation.new("12", "ActiveGraph")
end
end
loader.setup
# loader.eager_load
Expand Down
4 changes: 2 additions & 2 deletions lib/active_graph/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def initialize(path = default_path)
end

def migrate
ActiveSupport::Deprecation.warn '`AddIdProperty` task is deprecated and may be removed from future releases. '\
'Create a new migration and use the `populate_id_property` helper.', caller
ActiveGraph.deprecator.warn '`AddIdProperty` task is deprecated and may be removed from future releases. ' \
'Create a new migration and use the `populate_id_property` helper.', caller
models = ActiveSupport::HashWithIndifferentAccess.new(YAML.load_file(models_filename))[:models]
output 'This task will add an ID Property every node in the given file.'
output 'It may take a significant amount of time, please be patient.'
Expand Down
2 changes: 1 addition & 1 deletion lib/active_graph/node/has_n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ module ClassMethods

# :nocov:
def has_association?(name)
ActiveSupport::Deprecation.warn 'has_association? is deprecated and may be removed from future releases, use association? instead.', caller
ActiveGraph.deprecator.warn 'has_association? is deprecated and may be removed from future releases, use association? instead.', caller

association?(name)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/active_graph/node/id_property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def id_property(name, conf = {}, inherited = false)

# rubocop:disable Naming/PredicateName
def has_id_property?
ActiveSupport::Deprecation.warn 'has_id_property? is deprecated and may be removed from future releases, use id_property? instead.', caller
ActiveGraph.deprecator.warn 'has_id_property? is deprecated and may be removed from future releases, use id_property? instead.', caller

id_property?
end
Expand Down
2 changes: 1 addition & 1 deletion lib/active_graph/node/labels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def mapped_label_name=(name)

# rubocop:disable Naming/AccessorMethodName
def set_mapped_label_name(name)
ActiveSupport::Deprecation.warn 'set_mapped_label_name is deprecated, use self.mapped_label_name= instead.', caller
ActiveGraph.deprecator.warn 'set_mapped_label_name is deprecated, use self.mapped_label_name= instead.', caller

self.mapped_label_name = name
end
Expand Down
2 changes: 1 addition & 1 deletion lib/active_graph/node/query/query_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def identity
# The relationship identifier most recently used by the QueryProxy chain.
attr_reader :rel_var
def rel_identity
ActiveSupport::Deprecation.warn 'rel_identity is deprecated and may be removed from future releases, use rel_var instead.', caller
ActiveGraph.deprecator.warn 'rel_identity is deprecated and may be removed from future releases, use rel_var instead.', caller

@rel_var
end
Expand Down
2 changes: 1 addition & 1 deletion lib/active_graph/node/scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def scope(name, proc)

# rubocop:disable Naming/PredicateName
def has_scope?(name)
ActiveSupport::Deprecation.warn 'has_scope? is deprecated and may be removed from future releases, use scope? instead.', caller
ActiveGraph.deprecator.warn 'has_scope? is deprecated and may be removed from future releases, use scope? instead.', caller

scope?(name)
end
Expand Down
4 changes: 4 additions & 0 deletions lib/active_graph/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def empty_config
end
end

initializer "activegraph.deprecator" do |app|
app.deprecators[:activegraph] = ActiveGraph.deprecator
end

def setup!(config = empty_config)
config = final_driver_config!(config)
scheme = config.delete(:scheme) || 'bolt'
Expand Down
2 changes: 1 addition & 1 deletion lib/active_graph/relationship/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def last
private

def deprecation_warning!
ActiveSupport::Deprecation.warn 'The ActiveGraph::Relationship::Query module has been deprecated and will be removed in a future version of the gem.', caller
ActiveGraph.deprecator.warn 'The ActiveGraph::Relationship::Query module has been deprecated and will be removed in a future version of the gem.', caller
end

def where_query
Expand Down
2 changes: 1 addition & 1 deletion lib/active_graph/shared/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def inject_timestamps!

def set_timestamps
warning = 'This method has been replaced with `inject_timestamps!` and will be removed in a future version'.freeze
ActiveSupport::Deprecation.warn warning, caller
ActiveGraph.deprecator.warn warning, caller
inject_timestamps!
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/e2e/relationship_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,9 @@ class ActiveRelSpecTypesInheritedRelClass < ActiveRelSpecTypesAutomaticRelType

describe 'objects and queries' do
around do |ex|
ActiveSupport::Deprecation.silenced = true
ActiveGraph.deprecator.silenced = true
ex.run
ActiveSupport::Deprecation.silenced = false
ActiveGraph.deprecator.silenced = false
end

let!(:rel1) { MyRelClass.create(from_node: from_node, to_node: to_node, score: 99) }
Expand Down

0 comments on commit 523a07e

Please sign in to comment.