structure.rb in structure-0.28.6 vs structure.rb in structure-0.29.0
- old
+ new
@@ -83,10 +83,18 @@
private
def attribute(name, &blk)
name = name.to_s
module_eval "def #{name}?; #{name}; end" if name.chomp!('?')
- module_eval "def #{name}; return @#{name} if defined?(@#{name}); @#{name} = _#{name}.freeze; end"
+ module_eval <<-DEF
+ def #{name}
+ return @#{name} if defined?(@#{name})
+ @#{name} = _#{name}
+ @#{name}.freeze unless @#{name}.is_a?(Structure)
+
+ @#{name}
+ end
+ DEF
define_method("_#{name}", blk)
private "_#{name}"
@attribute_names << name