Sha256: 789f55359af4e10a815dd110bf22da84d7ee99dfa8d403a12e9e49c9d06a6f84

Contents?: true

Size: 594 Bytes

Versions: 3

Compression:

Stored size: 594 Bytes

Contents

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

3 entries across 3 versions & 1 rubygems

Version Path
api_mailer-0.0.4 lib/api_mailer/configuration.rb
api_mailer-0.0.3 lib/api_mailer/configuration.rb
api_mailer-0.0.1 lib/api_mailer/configuration.rb