Sha256: 499fb8b1943c2488b891359fed779ebaf0bf53066d5f17a605118b4e1ce7777c
Contents?: true
Size: 1.4 KB
Versions: 1
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 /^(swedbank|seb|sampo|nordea)_(.*)=$/ =~ m.to_s clz = Ipizza::Provider.const_get($1.capitalize) key = $2 value = args.first value = normalize_file_location(value) if /^file_(cert|key)/ =~ key if clz.respond_to?(:"#{key}=") return clz.send(:"#{key}=", *[value]) end end super end private def normalize_file_location(file_path) if File.exists?(file_path) file_path else file_path = File.expand_path(File.join(certs_root, file_path)) end if File.exists?(file_path) file_path else raise "Could not load certificate from file '#{file_path}'" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ipizza-0.5.0 | lib/ipizza/config.rb |