Sha256: b13bd3cfa48305fed7e9634c0ca71a91f404990bcd54ecd49035677759e1ceb1

Contents?: true

Size: 434 Bytes

Versions: 24

Compression:

Stored size: 434 Bytes

Contents

module Sunzi
  module Cli::Database
    extend self

    attr_accessor :env

    def load_env(stage)
      path = File.expand_path('config/database.yml')
      @env = YAML.load(File.read(path))[stage]
      scope_keys
      @env = HashWithIndifferentAccess.new(@env)
    end

    private

    def scope_keys
      @env = @env.reduce({}) do |env, (key, value)|
        env[:"db_#{key}"] = value
        env
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
sunzi-rails-0.2.2 lib/sunzi/cli/database.rb
sunzi-rails-0.2.1 lib/sunzi/cli/database.rb
sunzi-rails-0.2.0 lib/sunzi/cli/database.rb
sunzi-rails-0.1.0 lib/sunzi/cli/database.rb