cartodb/app/controllers/carto/api/widget_presenter.rb
2020-06-15 10:58:47 +08:00

32 lines
588 B
Ruby

module Carto
module Api
class WidgetPresenter
def initialize(widget)
@widget = widget
end
def to_poro
return {} unless @widget
poro = {
id: @widget.id,
type: @widget.type,
title: @widget.title,
order: @widget.order,
layer_id: @widget.layer_id,
options: @widget.options,
style: @widget.style
}
poro[:source] = { id: @widget.source_id } if @widget.source_id.present?
poro
end
alias_method :to_vizjson, :to_poro
end
end
end