Skip to content

Commit 5a69f75

Browse files
committed
rubocop fixes
1 parent eb447b5 commit 5a69f75

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

activerecord-virtual_attributes.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
lib = File.expand_path("../lib", __FILE__)
1+
lib = File.expand_path("lib", __dir__)
22
$LOAD_PATH.push(lib) unless $LOAD_PATH.include?(lib)
33

44
require "active_record/virtual_attributes/version"
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
2222

2323
# Specify which files should be added to the gem when it is released.
2424
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
2626
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|bin)/}) || f.match(/^(\.)|renovate.json/) }
2727
end
2828

lib/active_record/virtual_attributes/rspec/have_virtual_attribute.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
RSpec::Matchers.define(:have_virtual_attribute) do |name, type|
22
match do |klass|
3-
expect(klass.has_attribute?(name)).to be_truthy
4-
expect(klass.virtual_attribute?(name)).to be_truthy
3+
expect(klass.has_attribute?(name)).to(be_truthy)
4+
expect(klass.virtual_attribute?(name)).to(be_truthy)
55
expect(klass.type_for_attribute(name.to_s).type).to(eq(type)) if type
66
klass.instance_methods.include?(name.to_sym)
77
end

lib/active_record/virtual_attributes/virtual_delegates.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def determine_method_names(column, to, prefix) # rubocop:disable Naming/MethodPa
105105
end
106106

107107
method_prefix = "#{prefix == true ? to : prefix}_" if prefix
108-
method_name = "#{method_prefix}#{method_name}".to_sym
108+
method_name = :"#{method_prefix}#{method_name}"
109109

110110
[method_name, to.to_sym, column]
111111
end

lib/active_record/virtual_attributes/virtual_fields.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module VirtualFields
66
include ActiveRecord::VirtualAttributes::VirtualReflections
77

88
# rubocop:disable Style/SingleLineMethods
9+
# rubocop:disable Naming/PredicateMethod
910
module NonARModels
1011
def dangerous_attribute_method?(_); false; end
1112

@@ -15,6 +16,7 @@ def add_autosave_association_callbacks(*_args); self; end
1516

1617
def belongs_to_required_by_default; false; end
1718
end
19+
# rubocop:enable Naming/PredicateMethod
1820
# rubocop:enable Style/SingleLineMethods
1921

2022
included do

lib/active_record/virtual_attributes/virtual_total.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,4 @@ def virtual_aggregate_arel(reflection, method_name, column)
116116
end
117117
end
118118

119-
ActiveRecord::Base.include VirtualAttributes::VirtualTotal
119+
ActiveSupport.on_load(:active_record) { include VirtualAttributes::VirtualTotal }

0 commit comments

Comments
 (0)