lib/rabl/builder.rb in rabl-0.1.1 vs lib/rabl/builder.rb in rabl-0.1.2

- old
+ new

@@ -64,13 +64,15 @@ alias_method :node, :code # Creates a child node that is included in json output # child(@user) { attribute :full_name } # child(@user => :person) { ... } + # child(@users => :people) { ... } def child(data, options={}, &block) return false unless data.present? name, object = data_name(data), data_object(data) - include_root = object.respond_to?(:each) # @users + include_root = object.respond_to?(:each) # child @users + object = { data_object(data) => data_name(data) } if data.respond_to?(:each_pair) # child :users => :people @_result[name] = self.object_to_hash(object, :root => include_root, &block) if resolve_condition(options) end # Glues data from a child node to the json_output # glue(@user) { attribute :full_name => :user_full_name } \ No newline at end of file