From 1cbbb00e3c6bcf4255fee485de3f2828ff2d1d4c Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Tue, 8 Mar 2016 10:41:14 -0500 Subject: refactor to_json calls --- src/guff/api-handler.cr | 2 +- src/guff/api/post.cr | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/guff') diff --git a/src/guff/api-handler.cr b/src/guff/api-handler.cr index 4d4a996..274e137 100644 --- a/src/guff/api-handler.cr +++ b/src/guff/api-handler.cr @@ -13,7 +13,7 @@ private macro define_method_calls(hash) context.request.query_params, "{{ namespace.id }}", "{{ method.id }}" - )) + )).to_json {% end %} else raise "unknown method" diff --git a/src/guff/api/post.cr b/src/guff/api/post.cr index 0bc6377..7141530 100644 --- a/src/guff/api/post.cr +++ b/src/guff/api/post.cr @@ -12,7 +12,7 @@ module Guff q: args["q"]? || "", tags: get_posts_tags(args["tags"]), page: args.has_key?("page") ? args["page"].to_i : 1, - ).to_json + ) end private def do_post_add_post( @@ -28,7 +28,7 @@ module Guff ) # return json - { post_id: post_id }.to_json + { post_id: post_id } end private def do_post_update_post( @@ -42,11 +42,11 @@ module Guff name: args["name"], body: args["body"], tags: args.has_key?("tags") ? get_tags(args["tags"]?) : nil, - posted: args["posted"]?, + posted: args.has_key?("posted") ? (args["posted"] == "t") : nil, ) # return json - { ok: true }.to_json + { ok: true } end private def do_post_remove_posts( @@ -60,7 +60,7 @@ module Guff }, ) - { ok: true }.to_json + { ok: true } end private def do_post_set_tags( @@ -73,7 +73,7 @@ module Guff tags: get_tags(args["tags"]?), ) - { ok: true}.to_json + { ok: true} end end end -- cgit v1.2.3