Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added signature to to_json, now callable like thing.to_json(:relation…

…ships => :foo)
  • Loading branch information...
commit c66e87cd23ffbb32c4f7a3e5359718a6d6fc897a 1 parent 2d1dee5
@BinaryPaean authored
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/dm-serializer/to_json.rb
View
6 lib/dm-serializer/to_json.rb
@@ -39,7 +39,11 @@ def as_json(options = {})
# TODO: This needs tests and also needs to be ported to #to_xml and
# #to_yaml
if options[:relationships]
- options[:relationships].each do |relationship_name, opts|
+ # check for symbol or string argument, and splat-collect if we have one
+ rel = options[:relationships]
+ rel = *rel if (rel.kind_of?(Symbol) || rel.kind_of?(String))
+ rel.each do |relationship_name, opts|
+ # opts will be null from splat, or with nested :relationships
opts ||= {}
if respond_to?(relationship_name)
result[relationship_name] = __send__(relationship_name).to_json(opts.merge(:to_json => false))
Please sign in to comment.
Something went wrong with that request. Please try again.