Sha256: 45367f8426c245dae9bebe51517b7102a99dc29ce7347271b85625b691ac5123

Contents?: true

Size: 1.14 KB

Versions: 14

Compression:

Stored size: 1.14 KB

Contents

module DockerizeRails
  class DRNameSpace
    require 'ostruct'

    @namespace = OpenStruct.new

    def self.load
      DRConfig.load_dockerize_rails_config
      load_from_app_config
      load_from_dockerize_rails_config
    end

    def self.load_from_app_config
      app_c = ConfigLoader.app_config
      databases = {}
      app_c.keys.each do |env|
        adapter = app_c[env]['adapter']
        databases[env] =
          if adapter.start_with?('mysql')
            'mysql'
          elsif adapter.start_with?('postgresql')
            'postgresql'
          elsif adapter.start_with?('sqlite')
            'sqlite'
          end
      end
      @namespace.databases = databases
      DRConfig.databases = databases
    end

    def self.load_from_dockerize_rails_config
      add_hash DRConfig.to_hash
    end

    def self.add_hash(hash)
      hash.map do |key, value|
        @namespace.send("#{key}=", value)
      end
    end

    def self.eval_i
      @namespace.instance_eval { binding }
    end

    class << self
      attr_reader :namespace

      private :load_from_app_config
      private :load_from_dockerize_rails_config
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
dockerize_rails-1.2.2 lib/dockerize_rails/dr_name_space.rb
dockerize_rails-1.2.1.beta.6 lib/dockerize_rails/dr_name_space.rb
dockerize_rails-1.2.1.beta.5 lib/dockerize_rails/dr_name_space.rb
dockerize_rails-1.2.1.beta.4 lib/dockerize_rails/dr_name_space.rb
dockerize_rails-1.2.1.beta.3 lib/dockerize_rails/dr_name_space.rb
dockerize_rails-1.2.1.beta.2 lib/dockerize_rails/dr_name_space.rb
dockerize_rails-1.2.0.beta.1 lib/dockerize_rails/dr_name_space.rb
dockerize_rails-1.1.0.beta.3 lib/dockerize_rails/dr_name_space.rb
dockerize_rails-1.1.0.beta.2 lib/dockerize_rails/dr_name_space.rb
dockerize_rails-1.1.0.beta.1 lib/dockerize_rails/dr_name_space.rb
dockerize_rails-1.0.4.beta.1 lib/dockerize_rails/dr_name_space.rb
dockerize_rails-1.0.3.beta.6 lib/dockerize_rails/dr_name_space.rb
dockerize_rails-1.0.3.beta.5 lib/dockerize_rails/dr_name_space.rb
dockerize_rails-1.0.3.beta.4 lib/dockerize_rails/dr_name_space.rb