Permalink
Browse files

[#177] Allow defining a subnode that doesn't represent a model object

  • Loading branch information...
1 parent 2474f96 commit 841833c0a6124684024fe53f8e5ac25e7bceb567 Sebastien Rosa committed May 3, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/rabl/builder.rb
View
@@ -88,7 +88,11 @@ def node(name, options={}, &block)
# child(@users => :people) { ... }
def child(data, options={}, &block)
return false unless data.present? && resolve_condition(options)
- name, object = data_name(data), data_object(data)
+ if options[:wrapper]
+ name, object = data.to_s, @_object
+ else
+ name, object = data_name(data), data_object(data)
+ end
include_root = is_collection?(object) && @options[:child_root] # child @users
engine_options = @options.slice(:child_root).merge(:root => include_root)
object = { object => name } if data.respond_to?(:each_pair) && object # child :users => :people

0 comments on commit 841833c

Please sign in to comment.