lib/rabl/builder.rb in rabl-0.1.3 vs lib/rabl/builder.rb in rabl-0.1.4
- old
+ new
@@ -69,10 +69,10 @@
# 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) # child @users
- object = { data_object(data) => data_name(data) } if data.respond_to?(:each_pair) # child :users => :people
+ object = { object => name } if data.respond_to?(:each_pair) && object # 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