Sha256: 77fce7cadd1fd813577e1bdef09732ba93ee7659934e84c6b9be75a2bbc8ee47

Contents?: true

Size: 803 Bytes

Versions: 2

Compression:

Stored size: 803 Bytes

Contents

module ActiveReporter
  class << self
    def database_type
      @database_type ||= case database_adapter
      when /postgres/ then :postgres
      when /mysql/ then :mysql
      when /sqlite/ then :sqlite
      else
        raise "unsupported database #{database_adapter}"
      end
    end

    def numeric?(value)
      value.is_a?(Numeric) || value.is_a?(String) && value =~ /\A\d+(?:\.\d+)?\z/
    end

    private

    def database_adapter
      @database_adapter ||= if ActiveRecord.gem_version < Gem::Version.new("6.1")
        ActiveRecord::Base.connection_config[:adapter]
      else
        ActiveRecord::Base.connection_db_config.adapter
      end
    end
  end
end

require "deeply_enumerable"
Dir.glob(File.join(__dir__, "active_reporter", "*/")).each { |file| require file.chomp("/") }

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_reporter-0.7.1 lib/active_reporter.rb
active_reporter-0.6.5 lib/active_reporter.rb