Skip to content

Commit fb7dece

Browse files
committed
Use default option for class_variable
There is a default option that pre-initialized the value. I noticed it is used in the attributes api, in which our code is based.
1 parent 74d042b commit fb7dece

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/active_record/virtual_attributes.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ def type
3838
ActiveRecord::Type.register(:symbol, Type::Symbol)
3939

4040
included do
41-
class_attribute :virtual_attributes_to_define, :instance_accessor => false
42-
self.virtual_attributes_to_define = {}
41+
class_attribute :virtual_attributes_to_define, :instance_accessor => false, :default => {}
4342
end
4443

4544
module ClassMethods

lib/active_record/virtual_attributes/virtual_delegates.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ module VirtualDelegates
1010
extend ActiveSupport::Concern
1111

1212
included do
13-
class_attribute :virtual_delegates_to_define, :instance_accessor => false
14-
self.virtual_delegates_to_define = {}
13+
class_attribute :virtual_delegates_to_define, :instance_accessor => false, :default => {}
1514
end
1615

1716
module ClassMethods

0 commit comments

Comments
 (0)