Slim option in library and title APIs

This commit is contained in:
Alex Ling
2021-04-25 12:39:08 +00:00
parent 7f0c256fe6
commit cd8944ed2d
4 changed files with 80 additions and 4 deletions
+12
View File
@@ -46,6 +46,18 @@ class Entry
file.close
end
def to_slim_json : String
JSON.build do |json|
json.object do
{% for str in ["zip_path", "title", "size", "id"] %}
json.field {{str}}, @{{str.id}}
{% end %}
json.field "title_id", @book.id
json.field "pages" { json.number @pages }
end
end
end
def to_json(json : JSON::Builder)
json.object do
{% for str in ["zip_path", "title", "size", "id"] %}