Skip to content

Commit

Permalink
hardening default option: only proc/lambda executes in the instance c…
Browse files Browse the repository at this point in the history
…ontext
  • Loading branch information
dmgr committed Oct 20, 2021
1 parent fceab9e commit 6dcefa7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_attr/attribute_defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _attribute_default(attribute_name)
default = self.class.attributes[attribute_name][:default]

case
when default.respond_to?(:call) then instance_exec(&default)
when default.is_a?(Proc) then instance_exec(&default)
when default.duplicable? then default.dup
else default
end
Expand Down

0 comments on commit 6dcefa7

Please sign in to comment.