Sha256: 6dc4278597cbd757060dff13cc1624f4e1c58fabbb4d0844647b068d758df79e

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

require 'ghost_adapter/config'

require 'ghost_adapter/railtie' if defined? ::Rails::Railtie

module GhostAdapter
  def self.config
    @@config ||= GhostAdapter::Config.new # rubocop:disable Style/ClassVars
  end

  def self.setup(options = {})
    new_config = GhostAdapter::Config.new(options)

    if defined? @@config
      @@config.merge!(new_config)
    else
      @@config = new_config # rubocop:disable Style/ClassVars
    end

    yield @@config if block_given?
  end

  def self.clear_config
    @@config = GhostAdapter::Config.new # rubocop:disable Style/ClassVars
  end

  module Internal
    @@ghost_migration_enabled = false # rubocop:disable Style/ClassVars

    def self.load_task
      return if @loaded

      load File.join(File.dirname(__FILE__), 'tasks', 'ghost_adapter.rake')

      @loaded = true
    end

    def self.enable_ghost_migration!
      @@ghost_migration_enabled = true # rubocop:disable Style/ClassVars
    end

    def self.ghost_migration_enabeld?
      env_val = ENV['GHOST_MIGRATE']&.downcase
      return false if %w[0 n no f false].include?(env_val)

      !!@@ghost_migration_enabled || %w[1 y yes t true].include?(env_val)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ghost_adapter-0.1.2 lib/ghost_adapter.rb
ghost_adapter-0.1.1 lib/ghost_adapter.rb
ghost_adapter-0.1.0 lib/ghost_adapter.rb