Commit 8373ced9 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'pl-project-service-filename-lineo' into 'master'

Provide filename and line number for `class_eval`

See merge request gitlab-org/gitlab-ce!32500
parents d3076322 e0ce29ad
......@@ -570,11 +570,6 @@ Style/EmptyMethod:
Style/Encoding:
Enabled: false
# Offense count: 2
Style/EvalWithLocation:
Exclude:
- 'app/models/service.rb'
# Offense count: 203
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
......
......@@ -174,7 +174,7 @@ class Service < ApplicationRecord
# Also keep track of updated properties in a similar way as ActiveModel::Dirty
def self.prop_accessor(*args)
args.each do |arg|
class_eval %{
class_eval <<~RUBY, __FILE__, __LINE__ + 1
unless method_defined?(arg)
def #{arg}
properties['#{arg}']
......@@ -198,7 +198,7 @@ class Service < ApplicationRecord
def #{arg}_was
updated_properties['#{arg}']
end
}
RUBY
end
end
......@@ -209,12 +209,12 @@ class Service < ApplicationRecord
self.prop_accessor(*args)
args.each do |arg|
class_eval %{
class_eval <<~RUBY, __FILE__, __LINE__ + 1
def #{arg}?
# '!!' is used because nil or empty string is converted to nil
!!ActiveRecord::Type::Boolean.new.cast(#{arg})
end
}
RUBY
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment