cartodb-4.42/app/controllers/carto/api/overlay_presenter.rb

31 lines
652 B
Ruby
Raw Normal View History

2024-04-06 13:25:13 +08:00
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