Class: Ipizza::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/ipizza/config.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.certs_rootObject

Returns the value of attribute certs_root.



7
8
9
# File 'lib/ipizza/config.rb', line 7

def certs_root
  @certs_root
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



25
26
27
# File 'lib/ipizza/config.rb', line 25

def configure
  yield self
end

.load_from_file(yaml_path) ⇒ Object



9
10
11
12
13
# File 'lib/ipizza/config.rb', line 9

def load_from_file(yaml_path)
  @certs_root = File.dirname(yaml_path)

  load_from_hash(YAML::load_file(yaml_path))
end

.load_from_hash(config) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/ipizza/config.rb', line 15

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

.method_missing(m, *args) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ipizza/config.rb', line 29

def method_missing(m, *args)
  if /^(lhv|swedbank|seb|sampo|krediidipank|nordea|luminor)_(.*)=$/ =~ 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