Skip to content

Commit

Permalink
Fix deprecation warning (#48)
Browse files Browse the repository at this point in the history
While working on a new feature for modis (#49) I noticed that calling
`deprecate` without passing in a deprecator instance is deprecated.
Thought I would address this apart from the larger feature PR.
  • Loading branch information
SxDx authored Jul 31, 2024
1 parent 229f317 commit 78b4d09
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/modis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require 'msgpack'

require 'modis/version'
require 'modis/deprecator'
require 'modis/configuration'
require 'modis/attribute'
require 'modis/errors'
Expand Down
7 changes: 7 additions & 0 deletions lib/modis/deprecator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module Modis
def self.deprecator
@deprecator ||= ActiveSupport::Deprecation.new('5.0', 'modis')
end
end
4 changes: 2 additions & 2 deletions lib/modis/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ def update(attrs)
end

alias update_attributes update
deprecate update_attributes: 'please, use update instead'
deprecate update_attributes: 'please, use update instead', deprecator: Modis.deprecator

def update!(attrs)
assign_attributes(attrs)
save!
end

alias update_attributes! update!
deprecate update_attributes!: 'please, use update! instead'
deprecate update_attributes!: 'please, use update! instead', deprecator: Modis.deprecator

private

Expand Down

0 comments on commit 78b4d09

Please sign in to comment.