Module: Classy::Yaml

Defined in:
lib/classy/yaml.rb,
lib/classy/yaml/engine.rb,
lib/classy/yaml/helpers.rb,
lib/classy/yaml/version.rb,
lib/classy/yaml/tag_helper.rb,
lib/classy/yaml/component_helpers.rb,
lib/classy/yaml/invalid_key_error.rb

Defined Under Namespace

Modules: ComponentHelpers, Helpers, TagHelper Classes: Engine, InvalidKeyError

Constant Summary collapse

VERSION =
"1.6.3"
@@default_file =
"config/utility_classes.yml"
@@engine_files =
[]
@@extra_files =
[]
@@override_tag_helpers =
false

Class Method Summary collapse

Class Method Details

.cached_default_yamlObject



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/classy/yaml.rb', line 65

def self.cached_default_yaml
  # Bypass cache in development and test environments
  return load_default_yaml if Rails.env.development? || Rails.env.test?

  # Use cache in other environments
  return @cached_default_yaml if @cached_default_yaml

  @load_lock.synchronize do
    return @cached_default_yaml if @cached_default_yaml
    @cached_default_yaml = load_default_yaml
  end
end

.cached_engine_yamlsObject

– Cached Data Accessors (Lazy Loading) –



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/classy/yaml.rb', line 51

def self.cached_engine_yamls
  # Bypass cache in development and test environments
  return load_engine_yamls if Rails.env.development? || Rails.env.test?

  # Use cache in other environments
  return @cached_engine_yamls if @cached_engine_yamls

  @load_lock.synchronize do
    # Double-check idiom to ensure loading happens only once
    return @cached_engine_yamls if @cached_engine_yamls
    @cached_engine_yamls = load_engine_yamls
  end
end

.default_file=(value) ⇒ Object



40
41
42
43
# File 'lib/classy/yaml.rb', line 40

def self.default_file=(value)
  @@default_file = value
  @cached_default_yaml = nil # Clear cache on reassignment
end

.engine_files=(value) ⇒ Object

– Configuration Setters with Path Resolution –



30
31
32
33
# File 'lib/classy/yaml.rb', line 30

def self.engine_files=(value)
  @@engine_files = Array.wrap(value).reject(&:blank?).map { |file| Rails.root.join(file) }
  @cached_engine_yamls = nil # Clear cache on reassignment
end

.extra_files=(value) ⇒ Object



35
36
37
38
# File 'lib/classy/yaml.rb', line 35

def self.extra_files=(value)
  @@extra_files = Array.wrap(value).reject(&:blank?).map { |file| Rails.root.join(file) }
  # Note: extra_files are not cached globally by default
end

.override_tag_helpers=(value) ⇒ Object



45
46
47
48
# File 'lib/classy/yaml.rb', line 45

def self.override_tag_helpers=(value)
  @@override_tag_helpers = value
  apply_tag_helper_override if value
end

.setup {|_self| ... } ⇒ Object

– Setup Method –

Yields:

  • (_self)

Yield Parameters:

  • _self (Classy::Yaml)

    the object that the method was called on



79
80
81
82
83
84
85
86
# File 'lib/classy/yaml.rb', line 79

def self.setup
  yield self
  # Clear all caches when configuration changes
  @cached_engine_yamls = nil
  @cached_default_yaml = nil
  # Apply tag helper override if enabled
  apply_tag_helper_override if @@override_tag_helpers
end