Skip to content

Instantly share code, notes, and snippets.

@marcoi
Created December 15, 2015 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcoi/c96fb66383147d096cf8 to your computer and use it in GitHub Desktop.
Save marcoi/c96fb66383147d096cf8 to your computer and use it in GitHub Desktop.
Responsebuilder for LRUG
class ResponseBuilder
def initialize(consumer, builder, object, *args)
@consumer = consumer
@builder = builder
@object = object
@args = args
end
def data_as_json
if @object.respond_to?(:map)
@object.map do |object|
@builder.new(@consumer, object, *@args).as_json
end
else
@builder.new(@consumer, @object, *@args).as_json
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment