-
-
Save marcoi/c96fb66383147d096cf8 to your computer and use it in GitHub Desktop.
Responsebuilder for LRUG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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