lib/jei/builders/relationship_node_builder.rb in jei-0.1.0 vs lib/jei/builders/relationship_node_builder.rb in jei-0.2.0

- old
+ new

@@ -1,15 +1,17 @@ module Jei - module Builder + module Builders module RelationshipNodeBuilder + include Nodes + # @param [Relationship] relationship # @param [Serializer] serializer # @return [RelationshipNode] def self.build(relationship, serializer) node = RelationshipNode.new(relationship) - if !relationship.options[:no_data] + if relationship.options[:data] node.children << case relationship when BelongsToRelationship build_data_node(relationship, serializer) when HasManyRelationship @@ -31,11 +33,11 @@ # @return [DataNode] def self.build_data_node(relationship, serializer) node = DataNode.new resource = relationship.evaluate(serializer) - serializer = Serializer.factory(resource) + serializer = Serializer.factory(resource, relationship.options[:serializer]) node.children << ResourceIdentifierNode.new(serializer) node end @@ -45,10 +47,10 @@ def self.build_collection_data_node(relationship, serializer) node = CollectionDataNode.new resources = relationship.evaluate(serializer) resources.each do |resource| - serializer = Serializer.factory(resource) + serializer = Serializer.factory(resource, relationship.options[:serializer]) node.children << ResourceIdentifierNode.new(serializer) end node end