Sha256: a889b77d6199d6c67269638f5526daba9df5a32a2f1bf98263a34770ea79f2fb
Contents?: true
Size: 1.4 KB
Versions: 2
Compression:
Stored size: 1.4 KB
Contents
require 'yaml' module Ipizza class Config class << self attr_accessor :certs_root def load_from_file(yaml_path) @certs_root = File.dirname(yaml_path) load_from_hash(YAML::load_file(yaml_path)) end def load_from_hash(config) config.each do |bank, params| params.each do |param, value| begin self.send(:"#{bank}_#{param}=", value) rescue NoMethodError; end end end end def configure yield self end def method_missing(m, *args) if /^(lhv|swedbank|seb|sampo|krediidipank|nordea)_(.*)=$/ =~ m.to_s clz = Ipizza::Provider.const_get($1.capitalize) key = $2 value = args.first value = load_certificate(value) if /^file_(cert|key)/ =~ key if clz.respond_to?(:"#{key}=") return clz.send(:"#{key}=", *[value]) end end super end private def load_certificate(file_path) if File.exist?(file_path) file_path else file_path = File.expand_path(File.join(certs_root, file_path)) end if File.exist?(file_path) file_path else raise "Could not load certificate from file '#{file_path}'" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ipizza-2.0.1 | lib/ipizza/config.rb |
ipizza-2.0.0 | lib/ipizza/config.rb |