class Maildotyml::Configuration
Attributes
environment[R]
file[R]
Public Class Methods
new(file, environment)
click to toggle source
# File lib/maildotyml/configuration.rb, line 9 def initialize(file, environment) @file, @environment = file, environment end
Public Instance Methods
delivery_method()
click to toggle source
# File lib/maildotyml/configuration.rb, line 13 def delivery_method parsed[:adapter].to_sym if parsed[:adapter] end
present?()
click to toggle source
# File lib/maildotyml/configuration.rb, line 21 def present? parsed.present? end
settings()
click to toggle source
# File lib/maildotyml/configuration.rb, line 17 def settings map_activerecord_style_keys(parsed.reject { |k,v| k == :adapter }) end
Private Instance Methods
map_activerecord_style_keys(settings)
click to toggle source
# File lib/maildotyml/configuration.rb, line 40 def map_activerecord_style_keys(settings) settings = settings.dup replace_hash_key(settings, :username, :user_name) replace_hash_key(settings, :host, :address) settings end
parsed()
click to toggle source
# File lib/maildotyml/configuration.rb, line 27 def parsed # TODO: What to do if there is no environment @_parsed ||= yaml.fetch(environment, {}).symbolize_keys end
replace_hash_key(hash, before, after)
click to toggle source
# File lib/maildotyml/configuration.rb, line 48 def replace_hash_key(hash, before, after) hash[after] = hash.delete(before) if hash[before] end
yaml()
click to toggle source
# File lib/maildotyml/configuration.rb, line 32 def yaml if file.exist? YAML.load ERB.new(file.read).result else {} end end