Sha256: d8fad3c6de7930da804e8d92b8a570d4a9fc2a8a149ed8244902709a90c60759

Contents?: true

Size: 716 Bytes

Versions: 11

Compression:

Stored size: 716 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 database_schema?
        database? && ::RedminePluginsHelper::Migration.from_code.all?(&:applied?)
      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

11 entries across 11 versions & 1 rubygems

Version Path
redmine_plugins_helper-0.15.3 lib/redmine_plugins_helper/available.rb
redmine_plugins_helper-0.15.2 lib/redmine_plugins_helper/available.rb
redmine_plugins_helper-0.15.1 lib/redmine_plugins_helper/available.rb
redmine_plugins_helper-0.15.0 lib/redmine_plugins_helper/available.rb
redmine_plugins_helper-0.14.0 lib/redmine_plugins_helper/available.rb
redmine_plugins_helper-0.13.2 lib/redmine_plugins_helper/available.rb
redmine_plugins_helper-0.13.1 lib/redmine_plugins_helper/available.rb
redmine_plugins_helper-0.13.0 lib/redmine_plugins_helper/available.rb
redmine_plugins_helper-0.12.2 lib/redmine_plugins_helper/available.rb
redmine_plugins_helper-0.12.1 lib/redmine_plugins_helper/available.rb
redmine_plugins_helper-0.12.0 lib/redmine_plugins_helper/available.rb