Class: Ace::Support::Config::Models::ConfigGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/support/config/models/config_group.rb

Overview

ConfigGroup represents a set of files sharing the same effective config

Constant Summary collapse

DEFAULT_SCOPE_NAME =

Default scope name when no path rule matches and no distributed config is found

"project default"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, source:, config:, files: [], rule_config: nil) ⇒ ConfigGroup



18
19
20
21
22
23
24
25
# File 'lib/ace/support/config/models/config_group.rb', line 18

def initialize(name:, source:, config:, files: [], rule_config: nil)
  @name = name
  @source = source
  @config = config || {}
  @rule_config = rule_config
  @files = Array(files)
  freeze
end

Instance Attribute Details

#configObject (readonly)

rule_config: Original path rule config (before cascade merge), used for grouping

- When a path rule matches, this contains only the rule's own overrides
- nil for distributed config matches or project default
- Separates grouping (use rule_config) from message generation (use config)


16
17
18
# File 'lib/ace/support/config/models/config_group.rb', line 16

def config
  @config
end

#filesObject (readonly)

rule_config: Original path rule config (before cascade merge), used for grouping

- When a path rule matches, this contains only the rule's own overrides
- nil for distributed config matches or project default
- Separates grouping (use rule_config) from message generation (use config)


16
17
18
# File 'lib/ace/support/config/models/config_group.rb', line 16

def files
  @files
end

#nameObject (readonly)

rule_config: Original path rule config (before cascade merge), used for grouping

- When a path rule matches, this contains only the rule's own overrides
- nil for distributed config matches or project default
- Separates grouping (use rule_config) from message generation (use config)


16
17
18
# File 'lib/ace/support/config/models/config_group.rb', line 16

def name
  @name
end

#rule_configObject (readonly)

rule_config: Original path rule config (before cascade merge), used for grouping

- When a path rule matches, this contains only the rule's own overrides
- nil for distributed config matches or project default
- Separates grouping (use rule_config) from message generation (use config)


16
17
18
# File 'lib/ace/support/config/models/config_group.rb', line 16

def rule_config
  @rule_config
end

#sourceObject (readonly)

rule_config: Original path rule config (before cascade merge), used for grouping

- When a path rule matches, this contains only the rule's own overrides
- nil for distributed config matches or project default
- Separates grouping (use rule_config) from message generation (use config)


16
17
18
# File 'lib/ace/support/config/models/config_group.rb', line 16

def source
  @source
end

Instance Method Details

#==(other) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/ace/support/config/models/config_group.rb', line 41

def ==(other)
  other.is_a?(self.class) &&
    other.name == name &&
    other.source == source &&
    other.config == config &&
    other.rule_config == rule_config &&
    other.files == files
end

#add_file(file) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/ace/support/config/models/config_group.rb', line 27

def add_file(file)
  self.class.new(
    name: name,
    source: source,
    config: config,
    rule_config: rule_config,
    files: files + [file]
  )
end

#file_countObject



37
38
39
# File 'lib/ace/support/config/models/config_group.rb', line 37

def file_count
  files.length
end

#inspectObject



50
51
52
# File 'lib/ace/support/config/models/config_group.rb', line 50

def inspect
  "#<#{self.class.name} name=#{name.inspect} files=#{files.length}>"
end