diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-03-06 18:08:34 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-03-06 18:08:34 -0500 |
commit | b89d53220afee70a991fe8c3ec694e32f1954ea0 (patch) | |
tree | ce65990beca3d70ca81b438048aaf0f5997f29e3 /src | |
parent | 5771ff1b239f8452a718cebcc2cf8ae49a93b3a9 (diff) | |
download | old-guff-b89d53220afee70a991fe8c3ec694e32f1954ea0.tar.bz2 old-guff-b89d53220afee70a991fe8c3ec694e32f1954ea0.zip |
populate postmodel stubs
Diffstat (limited to 'src')
-rw-r--r-- | src/guff/api-methods.cr | 12 | ||||
-rw-r--r-- | src/guff/model.cr | 4 | ||||
-rw-r--r-- | src/guff/models.cr | 2 | ||||
-rw-r--r-- | src/guff/post-model.cr | 19 |
4 files changed, 28 insertions, 9 deletions
diff --git a/src/guff/api-methods.cr b/src/guff/api-methods.cr index 6cc3087..f0df8bc 100644 --- a/src/guff/api-methods.cr +++ b/src/guff/api-methods.cr @@ -321,32 +321,28 @@ module Guff context : HTTP::Server::Context, args : Hash(String, String) ) - # TODO - [{foo: "bar"}, {foo: "asdf"}].to_json + @models.post.get_posts(args).to_json end private def do_post_add_post( context : HTTP::Server::Context, args : Hash(String, String) ) - # TODO: return post id - {ok: true}.to_json + @models.post.add_post(args).to_json end private def do_post_remove_posts( context : HTTP::Server::Context, args : Hash(String, String) ) - # TODO - {ok: true}.to_json + @models.post.remove_posts(args).to_json end private def do_post_set_tags( context : HTTP::Server::Context, args : Hash(String, String) ) - # TODO - {ok: true}.to_json + @models.post.set_tags(args).to_json end ############### diff --git a/src/guff/model.cr b/src/guff/model.cr index 823d33b..ce24427 100644 --- a/src/guff/model.cr +++ b/src/guff/model.cr @@ -2,5 +2,9 @@ module Guff class Model def initialize(@models : Models) end + + def db + @models.db + end end end diff --git a/src/guff/models.cr b/src/guff/models.cr index 7962c73..631be8d 100644 --- a/src/guff/models.cr +++ b/src/guff/models.cr @@ -4,7 +4,7 @@ require "./database-updater" private macro define_model_getters(hash) {% for name, klass in hash %} def {{ name.id }} - @cache[name] ||= {{ klass.id }}.new(self) + @cache[{{ name }}] ||= {{ klass.id }}.new(self) end {% end %} end diff --git a/src/guff/post-model.cr b/src/guff/post-model.cr index 20ccf22..e0e82a4 100644 --- a/src/guff/post-model.cr +++ b/src/guff/post-model.cr @@ -1,4 +1,23 @@ module Guff class PostModel < Model + def get_posts(req) + # TODO + [{foo: "bar"}, {foo: "asdf"}] + end + + def add_post(req) + # TODO: return post id + {ok: true} + end + + def remove_posts(req) + # TODO + {ok: true} + end + + def set_tags(req) + # TODO + {ok: true} + end end end |