Sha256: 72148ce4912012f12ec09d4cf91ec1e22e09ad087f002a6a2f3adc1b79d9f937
Contents?: true
Size: 876 Bytes
Versions: 2
Compression:
Stored size: 876 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.exist?(filepath) ActiveSupport::HashWithIndifferentAccess.new(load_yaml(ERB.new(File.read(filepath)).result)[Rails.env.to_s]) else raise Exception.new("File not found: config/api_mailer.yml") end end def load_yaml(source) # https://bugs.ruby-lang.org/issues/17866 # https://github.com/rails/rails/commit/179d0a1f474ada02e0030ac3bd062fc653765dbe begin YAML.load(source, aliases: true) rescue ArgumentError YAML.load(source) 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.9 | lib/api_mailer/configuration.rb |
api_mailer-0.0.8 | lib/api_mailer/configuration.rb |