Class: Ros::Console::Commands::TenantSelect

Inherits:
Pry::ClassCommand
  • Object
show all
Defined in:
lib/ros/core/console.rb

Instance Method Summary collapse

Instance Method Details

#process(id = nil) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
# 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