class Ros::Console::Commands::TenantSelect

Public Instance Methods

process(id = nil) click to toggle source
# File lib/ros/core/console.rb, line 74
def process(id = nil)
  if id.nil?
    # NOTE: This is dumb, but passing an array of field names to #pluck results in a noisy DEPRECATION WARNING
    if Tenant.column_names.include? 'name'
      output.puts Tenant.order(:id).pluck(:id, :schema_name, :name).each_with_object([]) { |a, ary| ary << a.join(' ') }
    else
      output.puts Tenant.order(:id).pluck(:id, :schema_name).each_with_object([]) { |a, ary| ary << a.join(' ') }
    end
    return
  end
  Apartment::Tenant.switch! Tenant.schema_name_for(id: id)
  Rails.configuration.x.memoized_shortcuts = {}
end