|
|
@ -1,28 +1,26 @@
|
|
|
|
class Video
|
|
|
|
macro add_mapping(mapping)
|
|
|
|
module HTTPParamConverter
|
|
|
|
def initialize({{*mapping.keys.map { |id| "@#{id}".id }}})
|
|
|
|
def self.from_rs(rs)
|
|
|
|
|
|
|
|
HTTP::Params.parse(rs.read(String))
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_a
|
|
|
|
|
|
|
|
return [{{*mapping.keys.map { |id| "@#{id}".id }}}]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def initialize(id, info, updated, title, views, likes, dislikes, wilson_score, published, description)
|
|
|
|
DB.mapping({{mapping}})
|
|
|
|
@id = id
|
|
|
|
|
|
|
|
@info = info
|
|
|
|
|
|
|
|
@updated = updated
|
|
|
|
|
|
|
|
@title = title
|
|
|
|
|
|
|
|
@views = views
|
|
|
|
|
|
|
|
@likes = likes
|
|
|
|
|
|
|
|
@dislikes = dislikes
|
|
|
|
|
|
|
|
@wilson_score = wilson_score
|
|
|
|
|
|
|
|
@published = published
|
|
|
|
|
|
|
|
@description = description
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def to_a
|
|
|
|
macro templated(filename)
|
|
|
|
return [@id, @info, @updated, @title, @views, @likes, @dislikes, @wilson_score, @published, @description]
|
|
|
|
render "src/views/#{{{filename}}}.ecr", "src/views/layout.ecr"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Video
|
|
|
|
|
|
|
|
module HTTPParamConverter
|
|
|
|
|
|
|
|
def self.from_rs(rs)
|
|
|
|
|
|
|
|
HTTP::Params.parse(rs.read(String))
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
DB.mapping({
|
|
|
|
add_mapping({
|
|
|
|
id: String,
|
|
|
|
id: String,
|
|
|
|
info: {
|
|
|
|
info: {
|
|
|
|
type: HTTP::Params,
|
|
|
|
type: HTTP::Params,
|
|
|
|