cartodb-4.42/app/models/visualization/name_checker.rb

24 lines
471 B
Ruby
Raw Normal View History

2024-04-06 13:25:13 +08:00
require_relative './collection'
module CartoDB
module Visualization
class NameChecker
def initialize(user)
@user = user
end
def available?(candidate)
!taken_names_for.include?(candidate)
end
private
def taken_names_for
@taken_names ||= Carto::Visualization::where(user_id: user.id).select(:name).map(&:name)
end
attr_reader :user
end # NameChecker
end # Visualization
end # CartoDB