We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5b60000 commit 56f393bCopy full SHA for 56f393b
lib/values.rb
@@ -23,6 +23,11 @@ def self.new(*fields, &block)
23
Class.new do
24
attr_reader(:hash, *fields)
25
26
+ # Unroll the fields into a series of assignment Ruby statements that can
27
+ # be used inside of the initializer for the new class. This was introduced
28
+ # in PR#56 as a performance optimization -- it ensures that this iteration
29
+ # happens once per class, instead of happening once per instance of the
30
+ # class.
31
instance_var_assignments = Array.new(fields.length) do |idx|
32
"@#{fields[idx]} = values[#{idx}]"
33
end.join("\n")
0 commit comments