Sha256: 6f35dd1bddb875fc46adeb6d8c76f1982fd29a54abc01d3e790f3e99ef8ce744

Contents?: true

Size: 609 Bytes

Versions: 2

Compression:

Stored size: 609 Bytes

Contents

require 'yaml'
ApiMailer::Configuration = Object.new

ApiMailer::Configuration.instance_eval do
  def filepath
    @filepath ||= Rails.root.join("config/api_mailer.yml")
  end
  def configurations
    @configurations ||= load_config
  end

  def load_config
    if File.exists?(filepath)
      ActiveSupport::HashWithIndifferentAccess.new(YAML.load(ERB.new(File.read(filepath)).result)[Rails.env.to_s])
    else
      raise Exception.new("File not found: config/api_mailer.yml")
    end
  end

  def get(name)
    configurations[name.to_s]
  end

  def keys
    configurations.keys
  end
  alias :[] :get
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
api_mailer-0.0.6 lib/api_mailer/configuration.rb
api_mailer-0.0.5 lib/api_mailer/configuration.rb