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

31 lines
652 B
Ruby

module Carto
module Api
class OverlayPresenter
PUBLIC_VALUES = [:id, :order, :type, :template, :options, :visualization_id].freeze
VIZJSON_VALUES = [:type, :order, :options, :template].freeze
def initialize(overlay)
@overlay = overlay
end
def to_poro
values(@overlay, PUBLIC_VALUES)
end
def to_vizjson_poro
values(@overlay, VIZJSON_VALUES)
end
alias_method :to_vizjson, :to_vizjson_poro
protected
def values(overlay, attribute_list)
Hash[attribute_list.map { |attribute| [attribute, overlay.send(attribute)] }]
end
end
end
end