class Shogun::Database
Constants
- CONFIGURATION
- DEFAULT_POOL
- DEFAULT_REAP_FREQUENCY
- DEFAULT_TIMEOUT
- DEFAULT_TIMEZONE
- POOL
- POOL_NAME
- REAP_FREQUENCY
- REAP_FREQUENCY_NAME
- TIMEOUT
- TIMEOUT_NAME
- TIMEZONE
- TIMEZONE_NAME
- URL
- URL_NAME
Public Class Methods
connection()
click to toggle source
# File lib/shogun/database.rb, line 23 def self.connection ActiveRecord::Base.connection end
new(logger:)
click to toggle source
# File lib/shogun/database.rb, line 34 def initialize(logger:) @logger = logger ActiveRecord::Base.time_zone_aware_attributes = true ActiveRecord::Base.default_timezone = (timezone || default_timezone).to_sym ActiveRecord::Base.logger = @logger ActiveRecord::LogSubscriber.logger = @logger ActiveRecord::LogSubscriber.colorize_logging = false ActiveRecord::Base.establish_connection(uri) end
setup!(logger:)
click to toggle source
# File lib/shogun/database.rb, line 27 def self.setup!(logger:) new(logger: logger).tap do connection.enable_extension("uuid-ossp") ActiveRecord::Base.descendants.each(&:setup!) end end
Private Instance Methods
configuration()
click to toggle source
# File lib/shogun/database.rb, line 56 def configuration self.class.const_get("CONFIGURATION") end
default_timezone()
click to toggle source
# File lib/shogun/database.rb, line 64 def default_timezone self.class.const_get("DEFAULT_TIMEZONE") end
query()
click to toggle source
# File lib/shogun/database.rb, line 52 def query configuration.to_query end
timezone()
click to toggle source
# File lib/shogun/database.rb, line 60 def timezone self.class.const_get("TIMEZONE") end
uri()
click to toggle source
# File lib/shogun/database.rb, line 48 def uri "#{url}?#{query}" end
url()
click to toggle source
# File lib/shogun/database.rb, line 44 def url self.class.const_get("URL") end