Provide filename and line number for class_eval
This commit removes one RuboCop offense from its todo file.
This commit is contained in:
parent
d3076322f2
commit
e0ce29ad06
2 changed files with 4 additions and 9 deletions
|
@ -570,11 +570,6 @@ Style/EmptyMethod:
|
||||||
Style/Encoding:
|
Style/Encoding:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Offense count: 2
|
|
||||||
Style/EvalWithLocation:
|
|
||||||
Exclude:
|
|
||||||
- 'app/models/service.rb'
|
|
||||||
|
|
||||||
# Offense count: 203
|
# Offense count: 203
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: EnforcedStyle.
|
# Configuration parameters: EnforcedStyle.
|
||||||
|
|
|
@ -174,7 +174,7 @@ class Service < ApplicationRecord
|
||||||
# Also keep track of updated properties in a similar way as ActiveModel::Dirty
|
# Also keep track of updated properties in a similar way as ActiveModel::Dirty
|
||||||
def self.prop_accessor(*args)
|
def self.prop_accessor(*args)
|
||||||
args.each do |arg|
|
args.each do |arg|
|
||||||
class_eval %{
|
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
||||||
unless method_defined?(arg)
|
unless method_defined?(arg)
|
||||||
def #{arg}
|
def #{arg}
|
||||||
properties['#{arg}']
|
properties['#{arg}']
|
||||||
|
@ -198,7 +198,7 @@ class Service < ApplicationRecord
|
||||||
def #{arg}_was
|
def #{arg}_was
|
||||||
updated_properties['#{arg}']
|
updated_properties['#{arg}']
|
||||||
end
|
end
|
||||||
}
|
RUBY
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -209,12 +209,12 @@ class Service < ApplicationRecord
|
||||||
self.prop_accessor(*args)
|
self.prop_accessor(*args)
|
||||||
|
|
||||||
args.each do |arg|
|
args.each do |arg|
|
||||||
class_eval %{
|
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
||||||
def #{arg}?
|
def #{arg}?
|
||||||
# '!!' is used because nil or empty string is converted to nil
|
# '!!' is used because nil or empty string is converted to nil
|
||||||
!!ActiveRecord::Type::Boolean.new.cast(#{arg})
|
!!ActiveRecord::Type::Boolean.new.cast(#{arg})
|
||||||
end
|
end
|
||||||
}
|
RUBY
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue