structure.rb in structure-0.28.3 vs structure.rb in structure-0.28.4

- old
+ new

@@ -2,11 +2,21 @@ def self.included(base) base.extend(ClassMethods).instance_variable_set(:@attribute_names, []) end def attributes - attribute_names.reduce({}) { |ret, name| - ret.update(name => self.send(name)) + attribute_names.reduce({}) { |ret, key| + val = self.send(key) + + ret.update(key => + if val.respond_to?(:attributes) + val.attributes + elsif val.is_a?(Array) + val.map { |el| el.respond_to?(:attributes) ? el.attributes : el } + else + val + end + ) } end def attribute_names self.class.attribute_names