aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-03-08 00:01:21 -0500
committerPaul Duncan <pabs@pablotron.org>2016-03-08 00:01:21 -0500
commit2d6635b4ff0393af6d97b93772bc566c331de08e (patch)
tree9cd8239047b1f6549dcb5883084e25b3f655322e /src
parentb8a4926107f273c1606a026687ebfcc74da147d4 (diff)
downloadold-guff-2d6635b4ff0393af6d97b93772bc566c331de08e.tar.bz2
old-guff-2d6635b4ff0393af6d97b93772bc566c331de08e.zip
add Post wrapper
Diffstat (limited to 'src')
-rw-r--r--src/guff/post-model.cr5
-rw-r--r--src/guff/post.cr10
2 files changed, 12 insertions, 3 deletions
diff --git a/src/guff/post-model.cr b/src/guff/post-model.cr
index 46e2dca..4a20db8 100644
--- a/src/guff/post-model.cr
+++ b/src/guff/post-model.cr
@@ -143,13 +143,13 @@ module Guff
":offset": ((page - 1) * limit).to_s,
":limit": limit.to_s,
}), tmpl_args) do |row|
- rows << row
+ rows << Post.new(row)
nil
end
end
# return result
- Results(Hash(String, ::SQLite3::Value)).new(
+ Results(Post).new(
page: page,
limit: limit,
num_rows: num_rows,
@@ -172,7 +172,6 @@ module Guff
"
private def get_tags_filter(tag_sets : Array(Array(String)))
- p tag_sets
(tag_sets.size > 0) ? template(:tags, {
"sql": tag_sets.map { |tags|
template(:tags, {
diff --git a/src/guff/post.cr b/src/guff/post.cr
new file mode 100644
index 0000000..7247e15
--- /dev/null
+++ b/src/guff/post.cr
@@ -0,0 +1,10 @@
+class Guff:Post
+ def initialize(@row : Hash(String, ::SQLite3::Value))
+ end
+
+ def to_json
+ @row.merge({
+ "tags": @row["tags"].split('|')
+ }).to_json
+ end
+end