Class: ConfCtl::ModuleOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/confctl/module_options.rb

Defined Under Namespace

Classes: Option

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nix: nil) ⇒ ModuleOptions

Returns a new instance of ModuleOptions.

Parameters:

  • nix (Nix, nil) (defaults to: nil)


61
62
63
64
# File 'lib/confctl/module_options.rb', line 61

def initialize(nix: nil)
  @nix = nix || Nix.new
  @options = []
end

Instance Attribute Details

#optionsArray<ModuleOptions::Option> (readonly)

Returns:



58
59
60
# File 'lib/confctl/module_options.rb', line 58

def options
  @options
end

Instance Method Details

#confctl_settingsObject



72
73
74
75
76
77
# File 'lib/confctl/module_options.rb', line 72

def confctl_settings
  options.select do |opt|
    opt.name.start_with?('confctl.') \
      && !opt.name.start_with?('confctl.swpins.')
  end
end

#machine_settingsObject



83
84
85
# File 'lib/confctl/module_options.rb', line 83

def machine_settings
  options.select { |opt| opt.name.start_with?('cluster.') }
end

#readObject



66
67
68
69
70
# File 'lib/confctl/module_options.rb', line 66

def read
  @options = nix.module_options.map do |opt|
    Option.new(opt)
  end
end

#service_settingsObject



87
88
89
# File 'lib/confctl/module_options.rb', line 87

def service_settings
  options.select { |opt| opt.name.start_with?('services.') }
end

#swpin_settingsObject



79
80
81
# File 'lib/confctl/module_options.rb', line 79

def swpin_settings
  options.select { |opt| opt.name.start_with?('confctl.swpins.') }
end