Skip to content

Commit

Permalink
Fix Ruby 2.7 deprecation warning for Proc.new
Browse files Browse the repository at this point in the history
Capturing the block implicitly using this mechanism is going to be
removed in Ruby 3.0 [1], so we need to explicitly pass the block in
future.

This change is backwards-compatible with other Ruby versions, it's just
slightly slower (~10x) [2].

[1]: https://bugs.ruby-lang.org/issues/10499
[2]: https://medium.com/@amliving/proc-new-trick-c1df16185599
  • Loading branch information
Nick Campbell committed Jan 8, 2020
1 parent aed8c4b commit 0bec8d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/statesman/adapters/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ def with_updated_timestamp(params)
end

class ActiveRecordAfterCommitWrap
def initialize
@callback = Proc.new
def initialize(&block)
@callback = block
@connection = ::ActiveRecord::Base.connection
end

Expand Down

0 comments on commit 0bec8d7

Please sign in to comment.