lib/active_shepherd/aggregate.rb in activeshepherd-0.8.2 vs lib/active_shepherd/aggregate.rb in activeshepherd-0.8.3

- old
+ new

@@ -31,10 +31,23 @@ def deserialize_value(attribute_name, value) run_through_serializer(attribute_name, value, :load) end + def in_namespace?(name) + my_namespace = model.class.to_s + if name == my_namespace + false + elsif name.deconstantize == my_namespace + true + elsif name.deconstantize == my_namespace.deconstantize && !name.deconstantize.blank? + true + else + false + end + end + private def associations @associations ||= begin all_associations = model.class.reflect_on_all_associations @@ -60,9 +73,10 @@ end def traverse_association?(association) return false if association.options[:readonly] return false if association.macro == :belongs_to + return false unless in_namespace?(association.klass.to_s) true end end