cartodb-4.42/app/models/visualization/name_checker.rb
2024-04-06 05:25:13 +00:00

24 lines
471 B
Ruby

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