diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-03-08 10:41:14 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-03-08 10:41:14 -0500 |
commit | 1cbbb00e3c6bcf4255fee485de3f2828ff2d1d4c (patch) | |
tree | f6527eaa77f8f8a7696384f66b81d5fdcea3988a | |
parent | 2c60a34cbe95d34950977e59d9316a1885b4fd6f (diff) | |
download | old-guff-1cbbb00e3c6bcf4255fee485de3f2828ff2d1d4c.tar.bz2 old-guff-1cbbb00e3c6bcf4255fee485de3f2828ff2d1d4c.zip |
refactor to_json calls
-rw-r--r-- | src/guff/api-handler.cr | 2 | ||||
-rw-r--r-- | src/guff/api/post.cr | 12 |
2 files changed, 7 insertions, 7 deletions
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 |