lib/rbbt/util/misc/annotated_module.rb in rbbt-util-5.25.28 vs lib/rbbt/util/misc/annotated_module.rb in rbbt-util-5.25.29
- old
+ new
@@ -3,11 +3,11 @@
def self.add_consummable_annotation(target, *annotations)
if annotations.length == 1 and Hash === annotations.first
annotations.first.each do |annotation, default|
target.send(:attr_accessor, annotation)
target.send(:define_method, "consume_#{annotation}") do
- value = instance_variable_get("@#{annotation}") || default.dup
- instance_variable_set("@#{annotation}", default.dup)
+ value = instance_variable_get("@#{annotation}") || (default.nil? ? nil : default.dup)
+ instance_variable_set("@#{annotation}", (default.nil? ? nil : default.dup))
value
end
end
else
annotations.each do |annotation|