Class: R509::Config::CAConfigPool
- Inherits:
-
Object
- Object
- R509::Config::CAConfigPool
- Defined in:
- lib/r509/config/ca_config.rb
Overview
pool of configs, so we can support multiple CAs from a single config file
Class Method Summary collapse
-
.from_yaml(name, yaml_data, opts = {}) ⇒ Object
Loads the named configuration config from a yaml string.
Instance Method Summary collapse
-
#[](name) ⇒ Object
retrieve a particular config by its name.
-
#all ⇒ Object
A list of all the configs in this pool.
-
#initialize(configs) ⇒ CAConfigPool
constructor
A new instance of CAConfigPool.
-
#names ⇒ Object
get all the config names.
- #to_h ⇒ Hash
- #to_yaml ⇒ YAML
Constructor Details
#initialize(configs) ⇒ CAConfigPool
Returns a new instance of CAConfigPool
19 20 21 |
# File 'lib/r509/config/ca_config.rb', line 19 def initialize(configs) @configs = configs end |
Class Method Details
.from_yaml(name, yaml_data, opts = {}) ⇒ Object
Loads the named configuration config from a yaml string.
52 53 54 55 56 57 58 59 |
# File 'lib/r509/config/ca_config.rb', line 52 def self.from_yaml(name, yaml_data, opts = {}) conf = YAML.load(yaml_data) configs = {} conf[name].each_pair do |ca_name, data| configs[ca_name] = R509::Config::CAConfig.load_from_hash(data, opts) end R509::Config::CAConfigPool.new(configs) end |
Instance Method Details
#[](name) ⇒ Object
retrieve a particular config by its name
29 30 31 |
# File 'lib/r509/config/ca_config.rb', line 29 def [](name) @configs[name] end |
#all ⇒ Object
Returns a list of all the configs in this pool
34 35 36 |
# File 'lib/r509/config/ca_config.rb', line 34 def all @configs.values end |
#names ⇒ Object
get all the config names
24 25 26 |
# File 'lib/r509/config/ca_config.rb', line 24 def names @configs.keys end |
#to_h ⇒ Hash
39 40 41 |
# File 'lib/r509/config/ca_config.rb', line 39 def to_h @configs.merge(@configs) { |_k, v| v.to_h } end |
#to_yaml ⇒ YAML
44 45 46 |
# File 'lib/r509/config/ca_config.rb', line 44 def to_yaml self.to_h.to_yaml end |