lib/render/graph.rb in render-0.0.3 vs lib/render/graph.rb in render-0.0.4

- old
+ new

@@ -47,16 +47,22 @@ end uri.to_s end - def render(inherited_properties = {}) + def render(inherited_properties = nil) self.inherited_data = inherited_properties + if (schema.type == Array) + explicit_data = inherited_data + else + explicit_data = inherited_data.is_a?(Hash) ? inherited_data : {} + explicit_data = explicit_data.merge!(relationship_data_from_parent) + end graph_data = DottableHash.new - inherited_data = relationship_data_from_parent.merge({ endpoint: endpoint }) - rendered_data = schema.render!(inherited_data) do |parent_data| + + rendered_data = schema.render!(explicit_data, endpoint) do |parent_data| loop_with_configured_threading(graphs) do |graph| if parent_data.is_a?(Array) graph_data[graph.title] = parent_data.inject([]) do |nested_data, element| nested_data << graph.render(element)[graph.title] end @@ -117,10 +123,10 @@ def value_from_inherited_data(key) relationships.each do |parent_key, child_key| if !inherited_data.is_a?(Hash) return inherited_data elsif (child_key == key) - return inherited_data.fetch(parent_key) + return inherited_data.fetch(parent_key, nil) end end nil end