lib/mongodoc/parent_proxy.rb in mongodoc-0.1.2 vs lib/mongodoc/parent_proxy.rb in mongodoc-0.2.0

- old
+ new

@@ -7,16 +7,25 @@ raise ArgumentError.new('ParentProxy require an association name') if assoc_name.blank? @_parent = parent @assoc_name = assoc_name end - def path_to_root(attrs) - assoc_attrs = attrs.inject({}) do |assoc_attrs, (key, value)| - assoc_attrs["#{assoc_name}.#{key}"] = value - assoc_attrs + def _path_to_root(src, attrs) + _parent._path_to_root(src, _annotated_keys(attrs)) + end + + def _selector_path_to_root(selector) + _parent._selector_path_to_root(_annotated_keys(selector)) + end + + protected + + def _annotated_keys(hash) + hash.inject({}) do |annotated, (key, value)| + annotated["#{assoc_name}.#{key}"] = value + annotated end - _parent.path_to_root(assoc_attrs) end private def method_missing(method, *args) @@ -30,6 +39,6 @@ else @_parent.send(method, *args) end end end -end \ No newline at end of file +end