module Vanity::Autoconnect

A singleton responsible for determining if the playground should connect to the datastore.

Constants

BLACKLISTED_RAILS_RAKE_TASKS
ENVIRONMENT_VANITY_DISABLED_FLAG

Public Class Methods

current_rake_tasks() click to toggle source
# File lib/vanity/autoconnect.rb, line 63
def current_rake_tasks
  ::Rake.application.top_level_tasks
rescue
  []
end
environment_disabled?() click to toggle source
# File lib/vanity/autoconnect.rb, line 55
def environment_disabled?
  !!ENV[ENVIRONMENT_VANITY_DISABLED_FLAG]
end
in_blacklisted_rake_task?() click to toggle source
# File lib/vanity/autoconnect.rb, line 59
def in_blacklisted_rake_task?
  !(current_rake_tasks & BLACKLISTED_RAILS_RAKE_TASKS).empty?
end
playground_should_autoconnect?()
Alias for: should_connect?
schema_relevant?() click to toggle source
# File lib/vanity/autoconnect.rb, line 51
def schema_relevant?
  current_rake_tasks.any? { |task| task =~ /\Adb:/ }
end
should_connect?() click to toggle source
# File lib/vanity/autoconnect.rb, line 46
def should_connect?
  !environment_disabled? && !in_blacklisted_rake_task?
end