Sha256: 2279de5871275f76ecdb02c31bac1dad19acc383f6d8c588700b93b034dcdee4

Contents?: true

Size: 596 Bytes

Versions: 1

Compression:

Stored size: 596 Bytes

Contents

# frozen_string_literal: true

module RedminePluginsHelper
  module Available
    class << self
      def database?
        ::ActiveRecord::Base.connection
      rescue ActiveRecord::NoDatabaseError
        false
      else
        true
      end

      def model?(*model_classes)
        table?(*model_classes.map(&:table_name))
      end

      def table?(*table_names)
        return false unless database?

        table_names.all? { |table_name| ::ActiveRecord::Base.connection.table_exists?(table_name) }
      end

      def settings?
        model?(::Setting)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redmine_plugins_helper-0.11.0 lib/redmine_plugins_helper/available.rb