Skip to content

Commit

Permalink
Fixes Rails 7.2 dep warning
Browse files Browse the repository at this point in the history
  • Loading branch information
bendangelo committed Jun 28, 2024
1 parent 4d03d40 commit 112f41e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/rom/sql/extensions/rails_log_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,31 @@ def sql(event)
binds = payload[:binds].to_a.inspect if payload[:binds]

if odd?
name = color(name, :cyan, true)
sql = color(sql, nil, true)
name = color(name, :cyan, color_option)
sql = color(sql, nil, color_option)
else
name = color(name, :magenta, true)
name = color(name, :magenta, color_option)
end

debug " #{name} #{sql} #{binds}"
end

attr_reader :odd_or_even
private :odd_or_even

def odd?
@odd_or_even = !odd_or_even
end

private

def color_option
if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new('7.1')

Check failure on line 37 in lib/rom/sql/extensions/rails_log_subscriber.rb

View workflow job for this annotation

GitHub Actions / Style

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
{ color: true }

Check failure on line 38 in lib/rom/sql/extensions/rails_log_subscriber.rb

View workflow job for this annotation

GitHub Actions / Layout

Layout/SpaceInsideHashLiteralBraces: Space inside { detected.

Check failure on line 38 in lib/rom/sql/extensions/rails_log_subscriber.rb

View workflow job for this annotation

GitHub Actions / Layout

Layout/SpaceInsideHashLiteralBraces: Space inside } detected.
else
true
end
end
end
end
end
Expand Down

0 comments on commit 112f41e

Please sign in to comment.